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:
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Convert char to String in Java
Python Program to Count the Number of Digits Present In a Number
Python Program to Check Armstrong Number
Python Strings
Python Program to Make a Simple Calculator
Python String center()
Python str()
Python Package
Python Program to Print the Fibonacci sequence
Python filter()
Python Program to Create Pyramid Patterns
Python Program to Add Two Matrices
Python String find()
Java InputStream to String
Python break and continue
Python Program to Find Armstrong Number in an Interval
Machine Learning with Python for everyone - Mark E.Fenner
Python Program to Display Fibonacci Sequence Using Recursion
Python String index()
Python map()
Python Program to Calculate the Area of a Triangle
Python Tuple count()
Python Keywords and Identifiers
Python Program to Check If Two Strings are Anagram
Python String rindex()
Python String zfill()
Python String format_map()
Python Program to Find the Largest Among Three Numbers
Python Program to Measure the Elapsed Time in Python
Python Deep Learning Cookbook - Indra den Bakker
Python Program to Check if a Number is Positive, Negative or 0