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 sum()
Python Input, Output and Import
Convert char to String in Java
Python String title()
Python File I/O Operation
Python complex()
Python Program to Sort Words in Alphabetic Order
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python bytes()
Python String format()
Why String is Immutable in Java?
Python Program to Find the Sum of Natural Numbers
Python Program to Display Fibonacci Sequence Using Recursion
Python Program to Return Multiple Values From a Function
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Data Types
Python Set discard()
Python Program to Print the Fibonacci sequence
Python dict()
Python Program to Illustrate Different Set Operations
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python Program to Convert Two Lists Into a Dictionary
Python String splitlines()
Python Program to Randomly Select an Element From the List
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Java String to InputStream
Python Program to Find Armstrong Number in an Interval
Python Program to Remove Punctuations From a String
Python List pop()
Python Type Conversion and Type Casting
Python String rpartition()