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 Program to Shuffle Deck of Cards
Python Program to Convert Decimal to Binary Using Recursion
Count Occurrences of a Char in a String
Python staticmethod()
Java String Conversions
Python Program to Slice Lists
Python bin()
Python List extend()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Program to Check if a Number is Odd or Even
Converting a Stack Trace to a String in Java
Python Set symmetric_difference()
Python open()
Array to String Conversions
Python Program to Find the Factors of a Number
Python List sort()
Adding a Newline Character to a String in Java
Generate a String
Python Program to Check If a List is Empty
Python Dictionary fromkeys()
Python Generators
Python Program to Count the Number of Occurrence of a Character in String
Python Strings
Python Dictionary items()
Python len()
Python Input, Output and Import
Python Program to Return Multiple Values From a Function
Python Program to Randomly Select an Element From the List
String Initialization in Java
Converting a List to String in Java
Python Program to Swap Two Variables
Python exec()