check if input is int or string python code example
Example 1: python check if string is in input
try:
val = int(userInput)
except ValueError:
print("That's not an int!")
Example 2: pyton how to tell if string is a int or string
def RepresentsInt(s):
try:
int(s)
return True
except ValueError:
return False