I got a value error and even if I try playing around with the code, it doesn\'t work!
How can I get it right? - I am using Python 3.3.2!
Here is the code:
You need to take into account that the user might not fill in a proper value:
try:
miles = float(input("How many miles can you walk? "))
except ValueError:
print("That is not a valid number of miles")
A try/except handles the ValueError
that might occur when float
tries to convert the input to a float.