Expect to get this to return False as the string contains an integer
def is_float(s):
try:
float(s)
return True
except ValueError:
return False
list1 =[['a','4'],['20.1','4'],['100','4'],['102','10'],['31.3','10'],['c','10'],['113','12'],['s','12'],['32.9','12']]
print(is_float(list1[6][0]))
This returns true when the value is 113. I would expect a False as the number is an integer?
Aucun commentaire:
Enregistrer un commentaire