The isalpha function in Python returns True when every character within the string is an alphabetic character. Conversely, it returns False if any of the characters are non-alphabetic. The function will yield either a True or False result.
Syntax of Python String isalpha Method
It has the following syntax:
isalpha()
Parameters
No parameter is required.
Return
It returns either True or False.
Different Examples for isalpha Method in Python
Let us examine a few instances of the isalpha method to gain a better comprehension of its capabilities.
Example 1
To illustrate the functionality of the isalpha method in Python, let’s consider an example.
# Python isalpha() method example
# Variable declaration
str = "Example"
# Calling function
str2 = str.isalpha()
# Displaying result
print(str2)
Output:
Example 2
Let’s consider an additional example to illustrate the isalpha method in Python.
# Python isalpha() method example
# Variable declaration
str = "Welcome to the C# Tutorial"
# Calling function
str2 = str.isalpha()
# Displaying result
print(str2)
Output:
Example 3
In this section, we will illustrate the functionality of the isalpha method in Python.
# Python isalpha() method example
# Variable declaration
str = "Example"
if str.isalpha() == True:
print("String contains alphabets")
else: print("Stringn contains other chars too.")
Output:
String contains alphabets