English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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() does not accept any parameters.
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.
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
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: