My python program asks the user to input any random number, stores them in the appropriate variables, then displays them in the final statement. I have no idea why the actual variables do not show the counted inputs. I am stuck and confused.
countOne = 0
countTwo = 0
countThree = 0
countFour = 0
countFive = 0
countSix = 0
print("Welcome")
print("This program is determines how often a certain number appears after the dice have been tossed")
print("You will toss your dice then input the number rolled. After you have entered in the information, the program will tell you how many times the number appears")
userInput=int(input("Please enter the number shown(1-6) or enter 0 to quit: "))
for i in range(1, 6):
if userInput == 1:
countOne = countOne + 1
elif userInput == 2:
countTwo = countTwo + 1
elif userInput == 3:
countThree = countThree + 1
elif userInput == 4:
countFour = countFour + 1
elif userInput == 5:
countFive = countFive + 1
elif userInput == 6:
countSix = countSix + 1
while userInput != 0:
if userInput >= 0 and userInput <= 6:
userInput=int(input("Please enter the number shown(1-6) or enter 0 to quit: "))
else:
userInput=int(input("ERROR, NUMBER OUTSIDE RANGE!! Please enter the number shown(1-6) or enter 0 to quit: "))
print("Number 1 appeared: ",countOne," time.")
print("Number 2 appeared: ",countTwo," time.")
print("Number 3 appeared: ",countThree," time.")
print("Number 4 appeared: ",countFour," time.")
print("Number 5 appeared: ",countFive," time.")
print("Number 6 appeared: ",countSix," time.")
print("Thank you! Good Bye!")
It runs with no syntax error but will reply with the incorrect number.