I am using Python 3.0. I'm trying to ask the user to enter the string 'Small' or 'Medium' or 'Large' and give an error if none of those are entered and then ask for input again.
while True:
try:
car_type = str(input('The car type: '))
except ValueError:
print('Car type must be a word.')
else:
break
But this doesn't work? Even if a number is entered the program continues and comes to an error at the end.
Aucun commentaire:
Enregistrer un commentaire