Skip to main content

isalpha()

The isalpha() method in Python is a String Method that returns True if all characters in the string are alphabetic (letters), otherwise it returns False. It will return False if the string is empty or contains any non-alphabetic character.

Parameter Values

This function does not accept any parameters.

Return Values

The isalpha() method returns a bool, either True or False.

How to Use isalpha() in Python

Example 1:

The isalpha() method returns True if all characters in the string are alphabetic (a-z, A-Z), otherwise it returns False.

'Hello'.isalpha()  # Output: True
Example 2:

The isalpha() method also returns False if the string contains spaces or special characters.

'Hello World'.isalpha()  # Output: False
Example 3:

It can be useful for checking if a string contains only alphabetic characters before processing the string further.

'123'.isalpha()  # Output: False