Created
August 5, 2016 22:42
-
-
Save manichabba/f7f571369fb1826dac2f0bdcd58d269d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
name = raw_input("Enter file:") | |
if len(name) < 1 : name = "mbox-short.txt" | |
handle = open(name) | |
emails = list() | |
count = dict() | |
for line in handle: | |
if not line.startswith("From ") : continue | |
words = line.split() | |
emails.append (words[1]) | |
for email in emails: | |
count[email] = count.get(email,0) + 1 | |
bigcount = None | |
bigword = None | |
for email, count in count.items(): | |
if bigcount is None or count > bigcount: | |
bigword = email | |
bigcount = count | |
print bigword, bigcount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment