Table of Contents
The isalpha() method returns True if all characters in the string are alphabets. If not, it returns False.
The syntax of isalpha() is:
string.isalpha()
1. isalpha() Parameters
isalpha() doesn’t take any parameters.
2. Return Value from isalpha()
The isalpha() returns:
- True if all characters in the string are alphabets (can be both lowercase and uppercase).
- False if at least one character is not alphabet.
3. Example 1: Working of isalpha()
name = "Monica" print(name.isalpha()) # contains whitespace name = "Monica Geller" print(name.isalpha()) # contains number name = "Mo3nicaGell22er" print(name.isalpha())
Output
True False False
4. Example 2: Working of isalpha()
name = "MonicaGeller"
if name.isalpha() == True:
print("All characters are alphabets")
else:
print("All characters are not alphabets.")
Output
All characters are alphabets
Checkout these related String methods as well:
- Python isalnum()
- Python isnumeric()
- Python isdigit()
- Python isdecimal()
Related posts:
Python set()
Python Program to Safely Create a Nested Directory
Converting a List to String in Java
Python Program to Split a List Into Evenly Sized Chunks
Python bytes()
Python Operator Overloading
Python Set issuperset()
Python isinstance()
Python Program to Compute the Power of a Number
Java String Conversions
Python Program to Convert Two Lists Into a Dictionary
Python Inheritance
Python Program to Find the Sum of Natural Numbers
Python Dictionary popitem()
Python String replace()
Python super()
Python repr()
Python Program to Display Powers of 2 Using Anonymous Function
Python Machine Learning Third Edition - Sebastian Raschka & Vahid Mirjalili
Python Machine Learning - Sebastian Raschka
Check If a String Is Numeric in Java
Deep Learning in Python - LazyProgrammer
Python Set difference_update()
Python Program to Merge Mails
Python String title()
Python Program to Display the multiplication Table
Python String istitle()
Jackson – Marshall String to JsonNode
Python Program to Calculate the Area of a Triangle
Python String expandtabs()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman