Is there a way in Python 3.3 to only except ValueError for strings? If I type a string into k, I want "Could not convert string to float" to be printed, rather than "Cannot take the square root of a negative number."
while True:
try:
k = float(input("Number? "))
....
except ValueError:
print ("Cannot take the square root of a negative number")
break
except ValueError:
print ("Could not convert string to float")
break
ValueError?except ValueErrorthere at all?ValueError: count not convert string to float: 'fdsdfsd'. For a negative number, you getValueError: math domain error.