我的问题是我的降雨用户输入总量不增加正确不能得到内部循环加起来正确
我的假设是,当多年问道
它不加入的第一个月def main():
#define accumulators
monthRain = 0
year = 0
monthTotal = 0
months = 0
total = 0
#get # of years
year = int(input("Enter the number of years to collect data for: "))
#define month total befor it is changed below with year + 1
monthTotal = year * 12
#define how many months per year
months = 12
#Find average rainfall per month
for year in range(year):
#accumulator for rain per month
total = 0
#get rainfall per month
print('\nNext you will enter 12 months of rainfall data for year', year + 1)
for month in range(months):
print("Enter the rainfall for month", month + 1, end=" ")
monthRain = float(input(': '))
#add monthly raingfall to accumulator
total += monthRain
average = total/monthTotal
#total months of data
print('\nYou have entered data for', monthTotal,'months')
#total rainfall
print('\nThe total rainfall for the collected months is:', total)
print('The average monthly rainfall for the collected months is:', format(average, '.2f'))
main()
我爱你......我会在4分钟内正确选择你的答案 –
没问题。快乐编程 –
这真的是我的大脑........它感觉很高兴知道这是一个小错误,造成这一切,一切工作完美:D –