integer in a string python check code example
Example 1: python test if string is int
'16'.isdigit()
>>>True
'3.14'.isdigit()
>>>False
'Some text'.isdigit()
>>>False
Example 2: python check if input is a number
user_input = input("Enter something:")
if type(user_input) == int:
return user_input
else:
print("Not a number")