I'm creating an application for my programming class and I'm unable to get it to run properly. Essentially, the application should take 8 numbers from the user and store them in an array and then add those numbers. However, if the user does not provide a number, or press Q, the program should stop.
userNumberList = []
counter = 0
while counter < 8:
try:
userNumber = int(input("Welcome! Please provide numbers or press q to quit. "))
except ValueError:
print("Not a number. Closing application.")
break
else:
if userNumber == 'q':
break
else:
userNumberList.append(int(userNumber))
counter += 1
print(sum(userNumberList))
This is the error I get when running typing a String instead of a number in the prompt:
userNumber = int(input("Welcome! Please provide numbers or press q to quit. "))
ValueError: invalid literal for int() with base 10: