Python String Method – isdigit()

Spread the love

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 –

  1. Python String Method – Capitalize()
  2. Python String Method – title()
  3. Python String Method – center()
  4. Python String Method – count()
  5. Python String Method – startswith()
  6. Python String Method – endswith()
  7. Python String Method – find()
  8. Python String Method – index()
  9. Python String Method – isalnum()
  10. Python String Method – isalpha()
  11. Python String Method – isdecimal()

Rating: 1 out of 5.

Leave a Reply