
Problem –
You want to check whether a string is a number in python.
Solution –
To check if a string is number use the isdigit() method.
In [1]: string1 = '123456'
In [2]: string1.isdigit()
Out[2]: True
In [3]: string2 = '123 456'
In [4]: string2.isdigit()
Out[4]: False
In [5]: string3 = 'python3'
In [6]: string3.isdigit()
Out[6]: False