I'm trying to teach myself python so I apologize if the question itself doesn't make much sense.
I am doing the examples of an online introductory to Python course I am sitting in on and the prompt is to write a code to read through a file and find all emails before adding them to a dictionary before printing out the person who had sent the most emails and the number they sent. My issue is that the prompt specifically asks for this to be done by sorting through the list in reverse order.
I managed to get the same end result simply by parsing out the names and then counting each time it popped up before finding the largest value and printing that out with the corresponding key in a for loop. However I was unsure if this is what I was supposed to do or if the book was asking for something else. Does the dictionary itself count as a list?
for k,v in di.items():
if largest_so_far ==-1
largest_so_far = v
elif v > largest_so_far :
largest_so_far = v
the_word = k
print(the_word,largest_so_far)
This is the code I used to print out the person with name emails. I tried changing
for k,v in di.items():
into
for k,v in reversed(di.items()):
in order to try and at least get some semblance of printing it out in reversed order but the code ran normally with no changes or issues.
Again, I apologize if this doesn't make much sense. I am almost entirely self taught(only able to watch prerecorded videos and read the text book) and am still trying to attain even a basic understanding of this language.