-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathex.9.4.py
More file actions
29 lines (27 loc) · 931 Bytes
/
ex.9.4.py
File metadata and controls
29 lines (27 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
9.4 Write a program to read through the mbox-short.txt and figure out who has
the most commits. 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 senders 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.
"""
#output
#cwen@iupui.edu 5
mail = dict()
Max_add = None
count = 0
fname = input("Enter file name : ")
fhand = open(fname)
for line in fhand :
if line.startswith('From '):
line = line.split()
M_add = line[1]
mail[M_add] = mail.get(M_add,0) + 1
else :
continue
for (add,value) in mail.items():
if value > count :
count = value
Max_add = add
print(Max_add,count)