isalpha Python Implementation with Examples

isalpha Python Implementation with Examples

Python has many inbuilt functions that can manipulate your inputs like string, integers, float e.t.c. Python isalpha() is one of them. It allows you to check whether there’s is alphabets in the string or not by returning boolean value true or false. In this entire tutorial, you will know how to implement isalpha() python function.

Examples of isalpha() python

Let’s know all the possible examples of isalpha() function in python.  Please note that I have implemented all the examples on the Jupyter Notebook. You can do it on your IDEs but I advise you to do it in the notebook for a better understanding. You can run your Jupyter notebook using the below command on your terminal.

jupyter notebook

Example 1:  Applying isalpha() on numeric characters

In this example, I have numeric characters in the string. And when I use isalpha() on it then I will get the false value.

string = "123456"
print(string.isalpha())

Output

applying isalpha on numeric characters
applying isalpha on numeric characters

Example 2: Applying isalpha() on alphabets only

Now let’s apply isalpha() on string with alphabets characters only. Execute the below lines of code.

string = "DataScienceLearner"
print(string.isalpha())

Output

applying isalpha on aplhabets only
applying isalpha on alphabets only

When you will run the above code you will get the true output. But in the case of the string containing alphabets with space between then isalpha() function will return false as space is another character in programming.

string = "Data Science Learner"
print(string.isalpha())

Output

applying isalpha on aplhabets only with space between
applying isalpha on aplhabets only with space between

Example 3: Apply isalpha() on an alphanumeric string

Let’s apply isalpha() function on a string containing both combinations of alphabets and numeric characters. When you will run the below lines of code you will get false output.

string = "DataScienceLearner123"
print(string.isalpha())

Output

applying isalpha on combination of alphabets and numeric characters
applying isalpha on the combination of alphabets and numeric characters

Conclusion

These are the examples of how to use isalpha() function in python. There can be much practical application of this function. And the most popular one is counting the number of alphabets in a given string. I hope this tutorial has cleared your query on how to use isaplha() method. If you have any doubt then you can contact us for more help.

Source:

Python Documentation

 

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Sukesh ( Chief Editor ), a passionate and skilled Python programmer with a deep fascination for data science, NumPy, and Pandas. His journey in the world of coding began as a curious explorer and has evolved into a seasoned data enthusiast.
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner