i'm attempting utilizing teamtreehouse learning subscription & starting out programming logic , design book attempt learning programming & python. please don't shoot kill me i'm having difficulty repetition structures!
goal: i'm attempting collect input user in outer loop. inner loop iterate 12 times per outer loop iteration calculating; getting rainfall of each month. outer loop then; display number of months, total inches of rainfall , average rainfall per month whole time period (1 or 7 etc years).
instead below error. i've tried changing code make counter variable string input in way can incrementing number printing out.
i found similar question @ below url though isn't making sense me don't understand .format in answer?
typeerror: input expected @ 1 arguments, got 3
error:
traceback (most recent call last): file "python", line 45, in <module> file "python", line 25, in userinput typeerror: input expected @ 1 arguments, got 2
code
#//////main program start////// #//////variable declaration////// years=0 timetraveling=0 months=12 totalmonths=0 rainaverage=0 rainfall=0 #//////variable declaration////// #//////user input function////// def userinput(): raintotal=0 print('this program calculate average rainfall on period of years.') years=int(input("please provide number of years calculate rainfall for.")) in range(1, years + 1): #////////////////testing variable values correct//////////////// #placeholder #////////////////testing variable values correct//////////////// #//////user input function////// in range(1, months + 1): raintotal=0 monthlyrainfall=int(input("please provide rainfall in inches month number:", i)) raintotal = raintotal + monthlyrainfall rainaverage=raintotal/months totalmonths=years*months #//////testing variable <> value assignment///// print(raintotal, 'inches of rain') #//////testing variable <> value assignment///// #///////// python code references///////////// # print('calculating total number of', totalmonths, 'months.') # print('months\t\t\t' + 'average rainfall') # print(rain, '\t\t\t\t\t', i) #/////////format references///////////// print("average rainfall per month:", raintotal/(years*12)) # after inner loop runs following should display # print('number of months # print('total inches of rainfall # print('average rainfall per month #//////calling function////// userinput() #//////calling function//////
you might want make line 25:
monthlyrainfall=int(input("please provide rainfall in inches month number:"+str(i) ))
if want print out value associated i