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 timestamp to datetime and vice-versa
Python enumerate()
Python String isalnum()
Python List clear()
Python Statement, Indentation and Comments
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Program to Check If Two Strings are Anagram
Python Program to Parse a String to a Float or Int
Deep Learning with Python - Francois Cholletf
Python Program to Print Colored Text to the Terminal
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python Program to Find the Sum of Natural Numbers
Python Set symmetric_difference()
Python Shallow Copy and Deep Copy
Python Program to Print Hello world!
Python for Loop
Python Program to Count the Occurrence of an Item in a List
Python Program to Find the Largest Among Three Numbers
Python setattr()
Machine Learning with Python for everyone - Mark E.Fenner
Python String istitle()
Python vars()
Python String capitalize()
Python Program to Find Factorial of Number Using Recursion
Python Sets
Python Program to Get File Creation and Modification Date
Python Program to Find the Square Root
Python String upper()
Python int()
Python Strings
Python Program to Get the Last Element of the List
Python String split()