A question about Hurricane Analysis Challenge Project (Python), Step 7

Hi everyone!

I’ve been doing the Hurricane Analysis Challenge Project and I got stuck at step 7!
I’ve come up with sort of a function, which is supposed to rates hurricanes on a mortality scale, creating a dictionary. However, the result if just one hurricane. Any suggestions about what went wrong?

death_toll_hurricanes = {name:death_toll for name, death_toll in zip(names, deaths)}
def categorize_death_toll(death_toll_hurricanes):
    deaths_mortality_scale = {}
    for value in death_toll_hurricanes.values():
        if deaths < 100:
            deaths_mortality_scale[0] = [key, value]
        elif deaths < 500:
            deaths_mortality_scale[1] = [key, value]
        elif deaths < 1000:
            deaths_mortality_scale[2] = [key, value]
        elif deaths < 10000:
            deaths_mortality_scale[3] = [key, value]
        elif deaths > 10000:
            deaths_mortality_scale[4] = [key, value]
        return deaths_mortality_scale
print(categorize_death_toll(death_toll_hurricanes))

Indentation is the key here. Everything your for loop is supposed to repeat has one level of indentation (that includes further levels). What does return do in a function?

2 Likes