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:
Jackson – Marshall String to JsonNode
Python abs()
Python classmethod()
Python Program to Convert String to Datetime
Python time Module
Python chr()
Python bin()
Python String format_map()
Python Program to Merge Two Dictionaries
Python String rindex()
Python Functions
APIs in Node.js vs Python - A Comparison
Converting a Stack Trace to a String in Java
Python help()
Python Program to Check if a Number is Positive, Negative or 0
Python List pop()
Encode a String to UTF-8 in Java
Python Program to Check Whether a String is Palindrome or Not
Python Program to Count the Number of Each Vowel
Python Program to Parse a String to a Float or Int
Python Program to Capitalize the First Character of a String
Python Program to Check if a Key is Already Present in a Dictionary
Python Program to Multiply Two Matrices
Python @property decorator
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python String startswith()
String Set Queries
JavaScript Methods of RegExp and String
Python String lower()
Python getattr()
Python Custom Exceptions
Python List