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:
Why String is Immutable in Java?
Python Program to Check If a String Is a Number (Float)
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python Program to Find ASCII Value of Character
Python RegEx
Python pass statement
Python sleep()
Python String zfill()
Python Decorators
Python String rjust()
Python hasattr()
Python Namespace and Scope
Python break and continue
Python globals()
APIs in Node.js vs Python - A Comparison
Python issubclass()
Python Type Conversion and Type Casting
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python Program to Get the Class Name of an Instance
Python String rstrip()
Python __import__()
Python Program to Trim Whitespace From a String
Python frozenset()
Python Program to Split a List Into Evenly Sized Chunks
Python Shallow Copy and Deep Copy
Python Program to Compute the Power of a Number
Python Program to Get Line Count of a File
Python Set pop()
Python Global, Local and Nonlocal variables
Python Program to Display Powers of 2 Using Anonymous Function
Java – String to Reader