You can use in-built function isdigit() to check if a string is a number (float) in Python as shown in the below example –
1 2 3 4 5 |
s1 = "12345678" s2 = "hello123456" print(s1.isdigit()) ## Returns True print(s2.isdigit()) ## Returns False |