English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python Basic Tutorial

Python flow control

Python Functions

Python Data Types

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python Reference Manual

Python string isalpha() usage and example

Python string methods

If all characters in the string are letters, the isalpha() method will return True. If not, it will return False.

The syntax of isalpha() is:

string.isalpha()

isalpha() parameters

isalpha() does not accept any parameters.

isalpha() return value

isalpha() returns:

  • True If all characters in the string are letters (both lowercase and uppercase).

  • False If at least one character is not a letter.

Example1:isalpha() works

name = "Monica"
print(name.isalpha())
# Contains spaces
name = "Monica Geller"
print(name.isalpha())
# Contains numbers
name = "Mo3nicaGell22er"
print(name.isalpha())

When running the program, the output is:

True
False
False

Example1:isalpha() works

name = "MonicaGeller"
if name.isalpha() == True:
   print("All characters are alphabets")
else:
    print("All characters are not alphabets.")

When running the program, the output is:

All characters are alphabets

Check the following related String methods:

Python string methods