-1
我有这个代码的平均降雨量,我一直试图弄清楚用户输入每月降雨量。但我不断收到此错误代码:蟒蛇 - 平均降雨量
File "/Users/brittneybutcher/Desktop/UM-Flint/Average Rainfall.py", line 17, in <module>
"Average rainfall: " + format(averagerainfall, ".2f"))
TypeError: bad operand type for unary +: 'str' "
有谁能告诉我它有什么问题吗?
for currentyear in range(1, usernumberofyears + 1):
for currentmonth in range(1, 13):
monthlyrainfallinches = float(input("Please type the inches of rainfall for month " + \
format(currentmonth, "d") + ", year " + format(currentyear, "d") + \
": "))
totalinchesofrainfall += monthlyrainfallinches
totalnumberofmonths += 1
averagerainfall = totalinchesofrainfall/totalnumberofmonths
print("Number of Months: " + format(totalnumberofmonths, "d"), "Total inches of rainfall: " \
+ format(totalinchesofrainfall, ".2f"), + \
"Average rainfall: " + format(averagerainfall, ".2f"))