0
How to use exception handling in a funcation.
A funcation take one argument as string and convert them in to float, if user put integer in argument then how to use try and except to find error ?
1 Answer
+ 3
Anil Swami
Do you want to convert string into float?
Would you give an example?
If it is something like
'1.002' then you can simply check the condition as
if '.' in string:
try:
variable = float(string)
except:
print('error!')
else:
print('integer detected')