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 return only Boolean value, True or False.

Let’s see some examples using python isalpha function.

Python string isalpha() method example:

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

Example 1:

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

Output will be:- True

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

Example 2:

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

Output will be:- True

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

Example 3:

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

Output will be:- False

In above example output will be False because str contain 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 with your friends who want to learn Python programming from scratch to advanced.

For More Information:- Click Here

Previous Article
Next Article

Was this post helpful?

Related Posts

Leave a Reply