I am not sure how to prevent a negative number from affecting the final calculations.
I don't know what else to try.
for month in months:
rainfall_answer = int(input("What was the rainfall in {}? ".format(month)))
if rainfall_answer < 0:
print("Input must be positive.")
rainfall_answer = int(input("What was the rainfall in {}? ".format(month)))
elif rainfall_answer > 0:
rainfall.append(rainfall_answer)
I expect the invalid input to not be included in the final results.