Hi Mark, Address identifies the email address with the maximum number of sends: c...@iupui.edu.
Secondly, we are missing a count on the number of messages sent by c...@iupui.edu, i.e., 5. Thirdly, maxval 'none' is not defined on line # 24 Questions: How do we define the value of none for the key maxval and retrieve a number count on the number of messages sent by c...@iupui.edu. NameError: Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_5.py in <module>() 22 ## find the greatest number of mail messages. 23 ---> 24 maxval = none 25 maxkee = none 26 for kee, val in count.items(): NameError: name 'none' is not defined In [52]: print address c...@iupui.edu Revised data: ## The program looks for 'From ' lines and takes the second ## word of those lines as the person who sent the mail. fname = raw_input("Enter file name: ") handle = open (fname, 'r') for line in handle: if line.startswith("From: "): address = line.split()[1] ## 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. count = dict() for wrd in address: count[wrd]= count.get(wrd,0) +1 ## After the dictionary is produced, the program reads ## through the dictionary using a maximum loop to ## find the greatest number of mail messages. maxval = none maxkee = none for kee, val in count.items(): if maxval == none or maxval <val: maxval = val maxkee = kee #items are printed print address Regards, Hal > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor