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 Display Calendar
Python Dictionary update()
Python Program to Add Two Matrices
Python Program to Merge Mails
Python dict()
Python pow()
Python time Module
Python getattr()
Convert Character Array to String in Java
Check If a String Is Numeric in Java
Python String title()
Python String format_map()
Python Program to Shuffle Deck of Cards
Python Program to Parse a String to a Float or Int
Python Set isdisjoint()
Python String upper()
Python range()
Python String capitalize()
Java Program to Permute All Letters of an Input String
Python String isspace()
Python Program to Compute the Power of a Number
Python Program to Calculate the Area of a Triangle
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python Generators
Python isinstance()
Python complex()
Python Errors and Built-in Exceptions
Java – Reader to String
Python type()
Python Program to Convert Celsius To Fahrenheit
Python Set union()
Java – String to Reader