Created
July 17, 2018 18:58
-
-
Save abdullahalbyati/3cfb19b5a640962c7ff2855a5b42f23a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
import operator | |
input_file = open("./data/follows.txt", 'r') | |
wordcount = Counter(input_file.read().split()) | |
input_file.close() | |
most_popular_alien = max(wordcount.items(), key=operator.itemgetter(1)) | |
print ("Task 1: Who are the most popular users?\n") | |
print ("-----------------------Answer--------------------------\n\n") | |
print ("Aline with the user name :- " + most_popular_alien[0] + " with total numbers of followers " + str(most_popular_alien[1] - 1)) | |
result = [v[0] for v in sorted(wordcount.items(), key=lambda kv: (-kv[1], kv[0]))] | |
for entry in result: | |
print(entry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment