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

Tutoriel de base Python

Python Flow Control

Fonctions en Python

Types de données en Python

Python File Operations

Python Objects and Classes

Python Date and Time

Advanced Python Knowledge

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 (can be lowercase and uppercase).

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

Example1:The working of isalpha()

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:The working of isalpha()

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

Also check the following related String methods:

Python string methods