Hello everyone,
I just wanted to know how I can check if a string input is a number?
You can try to convert the str into an int
or float
and catch the exception if it fails.
As the above post said, there are several ways, one of which is to use the variable.is_integer()
var=input("Enter a value")
if var.isint() == True:
return True
else:
return False