python check if string contains int code example
Example 1: python how to check if string contains only numbers
print("012345".isdecimal())
OUTPUT
True
print("a12345".isdecimal())
OUTPUT
False
Example 2: python test if string is int
'16'.isdigit()
>>>True
'3.14'.isdigit()
>>>False
'Some text'.isdigit()
>>>False