0
Q:

python check if number

txt = "565543"

x = txt.isnumeric()
    
print(x) #this will print out True
1

txt = "565543"

x = txt.isnumeric()

    
print(x) 
2
if type(variable) == int or type(variable) == float:
    isNumber = True
2
txt = "565543"

x = txt.isnumeric()

print(x) 
# Output True if String is all numbers
0
def num_there(s):
    return any(i.isdigit() for i in s)
0
>>> def hasNumbers(inputString):
...     return any(char.isdigit() for char in inputString)
... 
>>> hasNumbers("I own 1 dog")
True
>>> hasNumbers("I own no dog")
False
0

New to Communities?

Join the community