Skip to content

Instantly share code, notes, and snippets.

@manichabba
Created August 5, 2016 22:42
Show Gist options
  • Save manichabba/f7f571369fb1826dac2f0bdcd58d269d to your computer and use it in GitHub Desktop.
Save manichabba/f7f571369fb1826dac2f0bdcd58d269d to your computer and use it in GitHub Desktop.
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