How to check if a string can be converted to an integer in Python

1 Answer

0 votes
def isint(string):
    try:
        int(string)
        return True
    except ValueError:
        return False
        

print(isint("-937"))

print(isint("82374"))

print(isint("3.14"))

print(isint("f35"))





'''
run:
 
True
True
False
False
 
'''

 



answered Jul 15, 2022 by avibootz
...