Mar-03-2020, 04:29 AM
It is good practice to avoid misleading names in code. If it's months rainfall why name it day_rainfall
Another approach to solve the problem is to find max value index in rainfall list and using this index to find corresponding position in months list. Borrowing Larz60+ data:
day_rainfall = float(input(f" In {x} what was the rainfall for the month? "))
?Another approach to solve the problem is to find max value index in rainfall list and using this index to find corresponding position in months list. Borrowing Larz60+ data:
>>> rainfall = [1.1, 2.3, .5, 2, 3.1, .25, 1.1, 2.3, .5, 2, 3.1, .25] >>> months = ['January', 'February', 'March', 'April', 'May', ... 'June','July', 'August', 'September', 'October', 'November', 'December'] >>> f'{months[rainfall.index(max(rainfall))]} has the highest rainfall with {max(rainfall)} inches' 'May has the highest rainfall with 3.1 inches'Note that there are two months with rainfall of 3.1.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.