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 Set copy()
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python String join()
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python Program to Delete an Element From a Dictionary
Python Program to Copy a File
Python getattr()
Python String replace()
Python Program to Represent enum
Python pass statement
Python while Loop
Python callable()
Python Program to Check If a String Is a Number (Float)
Python String capitalize()
Java Program to Permute All Letters of an Input String
Python Program to Compute the Power of a Number
Python Global Keyword
Python del Statement
Python Program to Print the Fibonacci sequence
Python Program to Extract Extension From the File Name
Machine Learning with Python for everyone - Mark E.Fenner
Python Program to Check Prime Number
Python Program to Concatenate Two Lists
Python Program to Print Output Without a Newline
Python bytes()
Python Set difference_update()
Python Program to Transpose a Matrix
Python Data Structures and Algorithms - Benjamin Baka
Python Program to Compute all the Permutation of the String
Python max()
Python int()
Converting String to Stream of chars