Created
January 6, 2021 21:45
-
-
Save ayubmetah/77198352d611dcf981f67bd047f19796 to your computer and use it in GitHub Desktop.
Write a program to read through the mbox-short.txt and figure out who has sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count of the number of times they appea…
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
add=dict() | |
name = input("Enter file:") | |
handle = open(name,'r') | |
for mail in handle: | |
if not mail.startswith('From '): continue | |
text=mail.split() | |
text=text[1] | |
add[text]=add.get(text,0)+1 | |
print(text, add[text]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Write a program to read through the mbox-short.txt and figure out who has sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count of the number of times they appear in the file. After the dictionary is produced, the program reads through the dictionary using a maximum loop to find the most prolific committer.