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 Get the Full Path of the Current Working Directory
Python Set intersection()
Python Set copy()
Python Program to Print the Fibonacci sequence
Python List insert()
Python frozenset()
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python staticmethod()
Python Sets
Python Directory and Files Management
String Set Queries
Python enumerate()
Python Program to Append to a File
Python Program to Find ASCII Value of Character
Python String join()
Python bytearray()
Python Dictionary pop()
Python Global Keyword
Python Program to Display Fibonacci Sequence Using Recursion
Python Program to Convert Decimal to Binary Using Recursion
Python Statement, Indentation and Comments
Python Program to Reverse a Number
Java InputStream to String
CharSequence vs. String in Java
Python Program to Make a Simple Calculator
Python Program to Check if a Number is Positive, Negative or 0
Python Program to Get Line Count of a File
Python Dictionary items()
Python id()
Python break and continue
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python Type Conversion and Type Casting