Python verifique se o número
if type(variable) == int or type(variable) == float:
isNumber = True
Dr. Hippo
if type(variable) == int or type(variable) == float:
isNumber = True
colors = [11, 34.1, 98.2, 43, 45.1, 54, 54]
for x in colors:
if int(x) == x:
print(x)
#or
if isinstance(x, int):
print(x)
var.isdigit()
#return true if all the chars in the string are numbers
#return false if not all the chars in the string are numbers
N.is_integer()
def num_there(s):
return any(i.isdigit() for i in s)
>>> def hasNumbers(inputString):
... return any(char.isdigit() for char in inputString)
...
>>> hasNumbers("I own 1 dog")
True
>>> hasNumbers("I own no dog")
False