I'm new to Python - creating a program which adds up how many animals someone has.
If a user enters a string (e.g. types 'five' or anything else) the program breaks).
What do I need to do to stop the program from breaking & also return the user to the question options?
I have created a loop & an else statement which covers the integers.
loop = 1
while loop == 1:
a = int(input(
"Select A Question:"
"Dog Question: '1'"
"Cat Question: '2'"
"Rabbit Question: '3'"
"Calculate Total Animals: '4'"
"Enter one of the above options 1-4:"))
if a == 1:
f = int(input("How many doggos do you have?: "))
elif a == 2:
h = int(input("How many cats do you have?: "))
elif a == 3:
s = int(input("How many rabbits do you have?: "))
elif a == 4:
loop = 0
else:
print("Please enter a valid value e.g. '1', '2', '3'"
"To add up your animals '4'")