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 Input, Output and Import
Python Program to Check If a List is Empty
Python Program to Illustrate Different Set Operations
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python Tuple count()
Python Custom Exceptions
Python Strings
Python Set issubset()
Python datetime
Python Program to Make a Flattened List from Nested List
Python String istitle()
Python Set issuperset()
Python String translate()
Python String lstrip()
Python String rfind()
Deep Learning in Python - LazyProgrammer
Python str()
Python break and continue
Python Program to Display Fibonacci Sequence Using Recursion
Python File I/O Operation
Python Dictionary keys()
Python Set clear()
How to Get Started With Python?
Python Program to Randomly Select an Element From the List
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Program to Create Pyramid Patterns
Java InputStream to String
Python Set union()
Python String swapcase()
Python chr()
Python Program to Return Multiple Values From a Function
Format ZonedDateTime to String