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 open()
Python exec()
Python List append()
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Encode a String to UTF-8 in Java
Python pow()
Python Dictionary keys()
Python Program to Display the multiplication Table
Python oct()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python timestamp to datetime and vice-versa
Python Set copy()
Convert String to Byte Array and Reverse in Java
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Converting String to Stream of chars
Python Program to Check Leap Year
Python Custom Exceptions
Python min()
Array to String Conversions
Python Statement, Indentation and Comments
Python Program to Create Pyramid Patterns
Python Dictionary get()
Python Dictionary update()
Python Inheritance
Python Program to Safely Create a Nested Directory
Python Program to Check If a List is Empty
Python Sets
Python Program to Find the Size (Resolution) of a Image
Python Program to Check the File Size
Python Program to Count the Number of Occurrence of a Character in String
Python classmethod()
Python Functions