Python Try / Except
What is the correct way to use Try / Except?
I am pretty new to Python and just trying to learn this new technique so
any ideas why this doesn't work?
temp=input("Please choose an option: ")
try:
if temp == ("1"):
fc=input("Fahrenheit: ")
fer(int(fc))
if temp == ("2"):
cf=input("Celsius: ")
cel(int(cf))
except ValueError:
print("It looks like you input a value that wasn't a number!")
If you put a value in "temp" that isn't 1 or 2 than it should print that
it isn't a number but it doesn't, any ideas?
No comments:
Post a Comment