Menu Close

Python String isalpha() Method

Python string isalpha() method

In this tutorial, you will learn all about the Python string isalpha() method to check whether a string contains only alphabets or not. The string isalpha function is a built-in string function that returns a boolean value.


In the previous tutorial, we have seen the Python string index() method to get the index number for the first occurrence of the specified value.

Python string isalpha() method:

Python string isalpha method is a string method that returns True if a string contains only alphabets otherwise return False.

Parameter:

String isalpha() method does not support any parameter.

Return Type:

String isalpha function returns only Boolean value, True or False.

Let’s see some examples using the python isalpha function.

Python string isalpha() method example:

Here we will understand the string isalpha() method using various examples.

Example 1:


str = "Programming"
str2 = str.isalnum()
print(str2)

The output will be:- True

In the above example output will be True because str contains only alphabets.

Example 2:


str = "Programming Funda"
str2 = str.isalnum()
print(str2)

The output will be:- True

In the above example output will be True because str contains only alphabets.

Example 3:


str = "Programming12"
str2 = str.isalnum()
print(str2)

The output will be:- False

In the above example output will be False because str contains alphabets as well as digits.

Conclusion:

In this tutorial, you have learned the Python string isalpha() method to check whether a string contains alphabets or not.
If the string contains alphabets, Then the string isalpha function to return True otherwise return False.
I hope this tutorial will have helped you. if you like this article, please share it with your friends who want to learn Python programming from scratch to advanced.

For More Information:- Click Here

Python String split() Method
Python String upper() Method

Related Posts