Problem 1 : Revise a previous program as follows: Read and parse…

Question Answered step-by-step Problem 1 : Revise a previous program as follows: Read and parse… Problem 1 : Revise a previous program as follows: Read and parse the “From” lines and pull out the addresses from the line. Count the number of messages from each person using a dictionary. After all the data has been read, print the person with the most commits by creating a list of (count, email) tuples from the dictionary. Then sort the list in reverse order and print out the person who has the most commits. Enter a file name: mbox-short.txt c..n@iupui.edu 5 Enter a file name: mbox.txt z..n@umich.edu 195filename = input(‘Enter a file name:’) fhand = open(filename, ‘r’) email_addresses = {} # Dictionary for line in fhand: if line.startswith(‘From’): email = line.split()[1] email_addresses[email] = email_addresses.get(email, 0) + 1lst = [] # Listd for key, value in email_addresses.items(): lst.append((value, key))lst.sort(reverse=True) person_tuple = lst[0] #print(email_addresses) print(person_tuple[1], person_tuple[0]) Computer Science Engineering & Technology Python Programming COMPUTING 14 Share QuestionEmailCopy link Comments (0)