Hello Everyone! I have a problem that is driving me insane. I have tried different codes, with the same approach (I have seen that there are different and may be better ways to approach this problem, but I prefer to try to resolve this issue, as I would have without looking for other solution).
Anyway, the code seems to work, BUT the answer is wrong. Can anyone help me to understand what is happening?
> # Calculating the Deadliest Hurricane
> # find highest mortality hurricane and the number of deaths
> def max_killer(hur_details): #hur_details is the dictionary containing all the information about hurricanes
> max_mortality_cane = 'Cuba I'# random name, I have tried others but the result is the same
> number_of_deaths = 0
> for x,y in hur_details.items():
> if y["Death"] > number_of_deaths: #Death is a key in the sub- dictionary of hur-details
> number_of_deaths = y["Death"]
> max_mortality_cane = x
> return {max_mortality_cane: number_of_deaths}
> print(max_killer(hur_details))
When I run this code it returns the first values of the main dictionary (hur_details), so my guess is that I am not iterating, probably because I am not accessing the sub-dictionary, and this is where my newbie-self cry and lose.
Can some kind soul help me out?
Thank you so much!