The following code creates a dictionary of email addresses and how frequently each email appears. What is the best way to pull out the key and value for the email with the max frequency?
fname = input("Enter file:")
try:
fhand = open(fname)
except:
print('File cannot be opened:')
exit()
counts = dict()
for line in fhand:
if line.startswith('From:'):
words = line.split(' ', 1)[1]
words = words.rstrip('\n')
counts[words] = counts.get(words,0)+1
print(counts)