Skip to content

Commit a928524

Browse files
committed
I changed the emailid-dictionary program. Instead of using two loops, I used max and count function
1 parent 9d863b2 commit a928524

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

email id dictionary/dict1.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55
fname=input('Enter file name:')
66
fh=open(fname)
77
for line in fh:
8-
if not line.startswith('From'):
9-
continue
10-
if line.startswith('From:'):
8+
if not line.startswith('From '):
119
continue
10+
# if line.startswith('From:'):
11+
# continue
1212
id=line.split()
1313
mail=id[1]
1414
mails.append(mail)
15+
16+
freq_mail = max(mails, key=mails.count) #To find frequent mail
17+
print(freq_mail,mails.count(freq_mail)) #To find countof frequent mail
18+
19+
20+
21+
22+
"""
1523
for x in mails:
1624
counts[x]=counts.get(x,0)+1
1725
bigmail=None
@@ -21,3 +29,5 @@
2129
bigmail=key
2230
bigvalue=value
2331
print(bigmail, bigvalue)
32+
33+
"""

email id dictionary/mbox-short.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ BSP-1415 New (Guest) user Notification
126126
This automatic notification message was sent by Sakai Collab (https://collab.sakaiproject.org/portal) from the Source site.
127127
You can modify how you receive notifications at My Workspace > Preferences.
128128

129-
129+
From cwen@iupui.edu
130130

131131
From zqian@umich.edu Fri Jan 4 16:10:39 2008
132132
Return-Path: <postmaster@collab.sakaiproject.org>

0 commit comments

Comments
 (0)