Python String isalpha() Function

String in Python has built-in functions for almost every action to be performed on a string. Python String isalpha() function checks for the alphabets in a string and returns True if the string consists of only alphabets (a-z, A-Z).

Key Points :

  • Return Type: Boolean i.e. True or False
  • Parametric Values: No Parameters required
  • Blank Spaces are not considered as alphabets. Hence, blank spaces will return False.
  • Empty String also returns False.

String isalpha() Syntax


str_name here refers to the input string. And, isalpha() is inbuilt string function in python.

str_name = "Welcome"
print(str_name.isalpha())   # True

String isalpha() Examples

Different cases are given below.

Case 1: String contains whitespace

str_name = "Welcome User"
print(str_name.isalpha())   # False

Case 2: String contains numbers

str_name = "WelcomeUser1"
print(str_name.isalpha())   # False

Case 3: String contains special characters

str_name = "WelcomeU$er@"
print(str_name.isalpha())    # False

Case 4: String is empty

str_name = ' '
print(str_name.isalpha())    # False

Program to Print List of All Possible Alpha Characters in Python

The Unicode module can be used to check the alpha characters. The program is to print all alpha Unicode characters.

import unicodedata

total_count = 0
for i in range(2 ** 16):
    charac = chr(i)
    if charac.isalpha():
        print(u'{:04x}: {} ({})'.format(i, charac,, 'UNNAMED')))
        total_count = total_count + 1
print("Total Count of Alpha Unicode Characters = ",total_count)


Output All Alpha Unicode Characters
Output All Alpha Unicode Characters

It is just a glance of output as the actual output is lengthy. There are 48462 alpha characters in Unicode.