Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python verify if string is a float

# Interger will be flaged as True as well.
def isfloat(num):
    try:
        float(num)
        return True
    except ValueError:
        return False

print(isfloat('s12'))
False
print(isfloat('1.123'))
True
print(isfloat('456'))
True
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #python #verify #string #float
ADD COMMENT
Topic
Name
8+1 =