Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python verify if string is a integer

'3'.isdigit()
True
'276'.isdigit()
True
'Bob276'.isdigit()
False

# The definition below interger will be flaged "True" as well as float.
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 appdividend.com #
 
PREVIOUS NEXT
Tagged: #python #verify #string #integer
ADD COMMENT
Topic
Name
9+1 =