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 String startswith()
Python String rjust()
Python List count()
Python String center()
Python Program to Find Sum of Natural Numbers Using Recursion
Python String isprintable()
Python Program to Create Pyramid Patterns
Python strftime()
Python Program to Merge Mails
Python Program to Capitalize the First Character of a String
Python String isdigit()
Python Program to Remove Punctuations From a String
Python Operators
Python String format()
Python Set remove()
Python Set difference()
Python complex()
Python Dictionary popitem()
Python map()
Python delattr()
Python Functions
Python Set intersection_update()
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python dict()
Python List append()
Python String find()
Python String lstrip()
Python Program to Find Factorial of Number Using Recursion
Java – Generate Random String
Python Get Current time
Python Program to Transpose a Matrix
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...