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 capitalize()
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python Program to Make a Simple Calculator
CharSequence vs. String in Java
Python String rjust()
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Set copy()
Python object()
Python Program to Find the Square Root
Java String Conversions
String Processing with Apache Commons Lang 3
Python Program to Safely Create a Nested Directory
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Case-Insensitive String Matching in Java
Python frozenset()
Python Program to Check Armstrong Number
Convert Character Array to String in Java
Python Set discard()
Python Program to Convert Kilometers to Miles
Python Set clear()
Python File I/O Operation
Python String replace()
Java String to InputStream
Python Dictionary popitem()
Python Directory and Files Management
Python String strip()
Python Program to Get the File Name From the File Path
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python timestamp to datetime and vice-versa
Python Recursion
Python Set difference()