Python String Method – isalpha()

Spread the love

isalpha() Method –

isalpha() method returns True if all the characters of a string are alphabets and returns False if not.

Syntax –

string.isalpha()

Example –

In [1]: string1 = 'python'

In [2]: string1.isalpha()
Out[2]: True

In [3]: string2 = 'python3'

In [4]: string2.isalpha()
Out[4]: False

The second example contains a number along with the alphabets that is why it is False. If you want to check whether a string contains alphabets or numbers then we use isalnum() method.

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()

Rating: 1 out of 5.

Leave a Reply