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 String strip()
Python hex()
Python Program to Safely Create a Nested Directory
Java InputStream to String
Python hash()
Python String rstrip()
Python @property decorator
Python Program to Find LCM
Python list()
Python Program to Multiply Two Matrices
Python Statement, Indentation and Comments
Python String lstrip()
String Hashing
Python Recursion
Convert Character Array to String in Java
Python String swapcase()
Python List insert()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python timestamp to datetime and vice-versa
Python Program to Delete an Element From a Dictionary
Python String capitalize()
Reading an HTTP Response Body as a String in Java
Python Program to Count the Number of Each Vowel
Python Program to Print Hello world!
Python Program to Find the Square Root
Python Program to Make a Flattened List from Nested List
Python String startswith()
Python Program to Count the Number of Occurrence of a Character in String
Python setattr()
Python Numbers, Type Conversion and Mathematics
Python Program to Capitalize the First Character of a String
Python Program to Concatenate Two Lists