0
name = input("Enter file:")
if len(name) < 1 : name = "mbox-short.txt"
handle = open(name)
counts=dict() 
bigword=None
bigcount=None
for line in handle:
    if line.startswith('From:'):continue
    if line.startswith('From '):
        line=line.rstrip()
        x=line.split('From ')
        y=x[1]
        z=y.split()
        d=z[0]
        print(z[0]) 

ın the text there were many things and whit that it takes only user names such as 'sinemucari@gmail.com' now I want to take all this names there were like 30 names. and put them in to dictionary and count how much they were repeated and what is the most repeated one.

    for user in z[0]: 
            counts[user]=counts.get(user,0)+1
            print(counts)
        for user,count in counts.items():
            if bigcount is None or count>bigcount:
               bigword=user
               bigcount=count
               print(bigcount,bigword)
MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • If I understand you question correctly, you were able to successfully create a dictionary that maps each word to its number of occurrences. Your goal is to find the word in the dictionary with the largest value and output that word and value. – somil Jun 03 '20 at 17:16
  • 1
    does this answer your question? https://stackoverflow.com/questions/20510768/count-frequency-of-words-in-a-list-and-sort-by-frequency – bb1950328 Jun 03 '20 at 17:16
  • no I have to use dictionaries. this is not solution. my code is not working if you like ı can share txt to. pls help me ı am very close to get crayz. – Sinem Ucarı Jun 03 '20 at 17:59

0 Answers0