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:
JavaScript Methods of RegExp and String
Python Data Types
Python Machine Learning Second Edition - Sebastian Raschka & Vahid Mirjalili
Python Multiple Inheritance
Python String isdigit()
Python for Loop
Python Program to Print the Fibonacci sequence
Python hash()
Python String zfill()
Python Program to Add Two Matrices
Python filter()
Python compile()
Python type()
Map to String Conversion in Java
Python exec()
Python enumerate()
Node.js vs Python for Backend Development
Python List remove()
Python Deep Learning Cookbook - Indra den Bakker
Python Program to Print Output Without a Newline
Python Set issubset()
CharSequence vs. String in Java
Python List sort()
Python strptime()
Python Program to Sort Words in Alphabetic Order
Python Set copy()
Python Program to Illustrate Different Set Operations
Java – Reader to String
Python map()
Python callable()
Python issubclass()
Python String rjust()