Python String isalpha() Method

By Lenin Mishra

If you prefer to watch Youtube videos over reading blogs, check out our video on Python strings here.

Python String isalpha() method

The isalpha() method in Python returns True, if all characters are alphabets(a-z).

Syntax of isalpha() method
string.isalpha()

Returns True or False
Example 1

Code

s1 = "Pylenin"

print(s1.isalpha())

Output

True
Example 2 - Check for a sentence

Code

s1 = "Pylenin was born in 1992"

print(s1.isalpha())

Output

False
Example 3 - Check for special characters

Code

s1 = "pylenin1992@gmail.com"

print(s1.isalpha())

Output

False

As you can see, @ is not an alphabetic character.

Let’s check for random characters.

Code

s1 = "!#%&?"

print(s1.isalpha())

Output

False

Check out other commonly used Python string methods.

  1. How to create a string in Python?
  2. How to access characters in a Python string?
  3. How to replace characters in a string in Python?
  4. How to concatenate strings in Python?
  5. How to iterate through a string in Python?
  6. Check if a Substring is Present in a Given String in Python
  7. Escape sequences in Python String
  8. Python String Formatting - The Definitive Guide