May-25-2020, 08:50 PM
I agree with buran that your assignment is a bit too vague. It tells you to check the user's input, but not what to check for or or how to respond to invalid input.
I'd do something like this:
This will keep prompting until the user enters something that can be converted to a float.
I'd do something like this:
1 2 3 4 5 6 |
while True : try : temp = float ( input ( "Enter your dog's age: " )) break except ValueError: print ( 'Invalid input! Please enter numbers only.' ) |