>>> def hasNumbers(inputString): ... return any(char.isdigit() for char in inputString) ... >>> hasNumbers("I own 1 dog") True >>> hasNumbers("I own no dog") False
txt = "565543" x = txt.isnumeric() print(x) #this will print out True
>>> 'A'.isdigit() False >>> '1'.isdigit() True
txt = "565543" x = txt.isnumeric() print(x) # Output True if String is all numbers