我的嵌套循环有一些输出问题,通常我会使用break在代码中添加一些行或print()
当我在我的代码中使用print()时,我的输出看起来像是在新行上输入总数而不是我想要的
以下是我当前输出的图片,我需要一个空行;
第二件事:
我的代码没有正确计算信息以查找每月的总降雨量和平均降雨量。
代码如下
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: "))
#blank line
print()
#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('