Feb-14-2020, 08:18 PM
I'm not quite sure how to structure this question so I'm going to use an example
Let's say I have a program that asks a user for a number which I am going to use later
, I would do something like this
they would receive an error message. I want to be able to create an error message with a While True loop so that if they did type in the number in letter form, or if they input something incorrectly for a similar program wouldn't crash. Is there a way to do this?
Let's say I have a program that asks a user for a number which I am going to use later
, I would do something like this
number = int(input("Please give me a number: ")) answer = number + 4 print("Your number plus 4 is " + str(answer) )However, if the user inputs the letter form of the number such as "two" or "three"
they would receive an error message. I want to be able to create an error message with a While True loop so that if they did type in the number in letter form, or if they input something incorrectly for a similar program wouldn't crash. Is there a way to do this?