I am currently trying to make a a program to allow for the User to enter a Specific Month and then input the number of stamps they collected, and it would be able to loop as many times as the user would want to continue to add, however all the values only seem to go to January rather than the specified month the User wants their value added to. How do I change the code to have it go to the User-specified months?
I have already managed to code the information to allow the user to ask for the specific month and take in the values, but the problem is it all goes to January.
months = [['January', 0], ['February', 0], ['March', 0], ['April', 0], ['May', 0], ['June', 0], ['July', 0],
['August', 0], ['September', 0], ['October', 0], ['November', 0], ['December', 0]]
looper = 1
while looper == 1:
month_checker = str(input('Please enter the month you want to add to: '))
adder = int(input("Please Enter the amount of stamps collected for the month: "))
if month_checker == 'January' or 'january':
months[0][1] += adder
elif month_checker == 'February' or 'february':
months[1][1] += adder
elif month_checker == 'March' or 'march':
months[2][1] += adder
elif month_checker == 'April' or 'april':
months[3][1] += adder
elif month_checker == 'May' or 'may':
months[4][1] += adder
elif month_checker == 'June' or 'june':
months[5][1] += adder
elif month_checker == 'July' or 'july':
months[6][1] += adder
elif month_checker == 'August' or 'august':
months[7][1] += adder
elif month_checker == 'September' or 'september':
months[8][1] += adder
elif month_checker == 'October' or 'october':
months[9][1] += adder
elif month_checker == 'November' or 'november':
months[10][1] += adder
elif month_checker == 'December' or 'december':
months[11][1] += adder
else:
print("That is not a valid month.")
looper = int(input("Please enter a 1 to continue or a 0 to end it: "))
if looper == 0:
for el in months:
print(el)
When I type in a month other than January, the code would display the results, however rather than add the amount to the specific month, the value only adds to January.
Please enter the month you want to add to: february
Please Enter the amount of stamps collected for the month: 3
Please enter a 1 to continue or a 0 to end it: 0
['January', 3]
['February', 0]
['March', 0]
['April', 0]
['May', 0]
['June', 0]
['July', 0]
['August', 0]
['September', 0]
['October', 0]
['November', 0]
['December', 0]