Python String isalpha Method - Python Tutorial | Logic Practice
Python Course / Data Types / Python String isalpha Method

Python String isalpha Method

BLUF: This lesson on Python String isalpha Method provides a comprehensive guide to understanding and implementing this concept in Python. Whether you're a beginner or looking to refresh your knowledge, you'll find clear explanations and interactive code examples here.
Key Concept: Python String isalpha Method

Mastering Python String isalpha Method is essential for building efficient Python applications. Focus on the syntax and the best practices highlighted in this tutorial.

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:

Example

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.

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.

Example

# 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.

Example

# Python isalpha() method example

# Variable declaration

str = "Example"

if str.isalpha() == True:

    print("String contains alphabets")

else: print("Stringn contains other chars too.")

Output:

Output

String contains alphabets

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience