Python isalpha() method returns true if all characters in the string are alphabetic. It returns False if the characters are not alphabetic. It returns either True or False.
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’s see some examples of isalpha() method to understand it’s functionalities.
Example 1
Let us take an example to demonstrate the isalpha() Method in Python.
# Python isalpha() method example
# Variable declaration
str = "Javatpoint"
# Calling function
str2 = str.isalpha()
# Displaying result
print(str2)
Output:
True
Example 2
Let us take another example to demonstrate the isalpha() Method in Python.
# Python isalpha() method example
# Variable declaration
str = "Welcome to the Javatpoint"
# Calling function
str2 = str.isalpha()
# Displaying result
print(str2)
Output:
False
Example 3
Here, we are going to demonstrate the working of isalpha() Method in Python.
# Python isalpha() method example
# Variable declaration
str = "Javatpoint"
if str.isalpha() == True:
print("String contains alphabets")
else: print("Stringn contains other chars too.")
Output:
String contains alphabets
Leave a Reply