
isdigit() Method –
isdigit() method returns True if all characters of a string are digits otherwise it returns False.
Syntax –
string.isdigit()
Example –
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
Related Posts –
- Python String Method – Capitalize()
- Python String Method – title()
- Python String Method – center()
- Python String Method – count()
- Python String Method – startswith()
- Python String Method – endswith()
- Python String Method – find()
- Python String Method – index()
- Python String Method – isalnum()
- Python String Method – isalpha()
- Python String Method – isdecimal()