By Lenin Mishra
If you prefer to watch Youtube videos over reading blogs, check out our video on Python strings here.
isalpha() method in Python returns
True, if all characters are alphabets(a-z).
string.isalpha() Returns True or False
s1 = "Pylenin" print(s1.isalpha())
Example 2 - Check for a sentence
s1 = "Pylenin was born in 1992" print(s1.isalpha())
Example 3 - Check for special characters
s1 = "firstname.lastname@example.org" print(s1.isalpha())
As you can see,
@ is not an alphabetic character.
Let’s check for random characters.
s1 = "!#%&?" print(s1.isalpha())
Check out other commonly used Python string methods.
- How to create a string in Python?
- How to access characters in a Python string?
- How to replace characters in a string in Python?
- How to concatenate strings in Python?
- How to iterate through a string in Python?
- Check if a Substring is Present in a Given String in Python
- Escape sequences in Python String
- Python String Formatting - The Definitive Guide