The file „hacker_poll.txt“ contains the results of a poll with the question “What’s your favorite programming language?”
(started 2012, latest update October 2014)
Please read in the file and print out the top ten values.
data = []
fh = open("hacker_poll.txt")
for line in fh:
language, votes = line.strip().rsplit(None, 1)
data.append((language, int(votes)))
data.sort(key=lambda x: (x[1], x[0]), reverse = True)
top10 = data[:10]
print(top10)
https://news.ycombinator.com/item?id=3746692