×

Python String isalpha() method

Python String isalpha() method

The string.isalpha () method in Python returns a boolean value true if all characters in the  string are alphabetic else for any other value it returns false.

Syntax

isalpha() 

Parameter

NA

Return

This method returns a boolean value true if all characters in the string are alphabetic.

Example 1

 # Python programing explaining
 # the isalpha() method
 # initializing a alhabetic value 
 strVal = "JulyApril"; 
 # returning a boolean value if all the string characters are alphabetic
 bool= strVal.isalpha()
 # prinitng the boolean value
 print("The'",strVal,"' contains all alphabetic value:",bool) 

Output

The' JulyApril ' contains all alphabetic value: True

Example 2

 # Python programing explaining
 # the isalpha() method
 # initializing a string value
 strVal = "Hello"
 # validating if and else condition
 if strVal.isalpha() == True:
    print("All the characters of the specified string are alphabtes.")
 else:
     print("All the characters are not alphabtes.") 

Output

All the characters of the specified string are alphabtes.

Example 3

 # Python programing explaining
 # the isalpha() method
 # initializing a string value
 char1 = "HelloWorld" # will return true as the string is alphabetic
 print(char1.isalpha())
 # string containing whitespace
 char2 = "Hello World " # will return False as the string contains whitespace
 print(char2.isalpha())
 #passing special characters 
 char3 = "!Mo3nica*$Gell22er" # will return false as it contains special characters
 print(char3.isalpha())
 # passing alphanumeric 
 char4 = "hello133world"# will return False as it is alphanumeric
 print(char4.isalpha()) 

Output

 True
 False
 False
 False 

Related Topics

Python SymPy

A Python package for symbolic mathematics is called SymPy. Its goal is to develop into a fully-fledged computer algebra system (CAS) while maintaining the code as straightforward as possible to...

3 minutes read.

Python String rfind() method

The string. rfind() method in Python returns the highest index in the string if the substring sub is found else it returns -1 if the substring is not found. Syntax string.rfind(sub [,start [,end]]) Parameter sub: This parameter...

2 minutes read.

Notepad++ For Python

In this article, you are going to learn what notepad++ is and how it is integrated with python to use the python programming language. You can also learn how to...

4 minutes read.

Conditional Statements in python

In this article, we will learn about conditional statements and how to apply conditional statements in Python. A decision-making statement is another name for a conditional statement. Decision-making is an important...

5 minutes read.

Syntax of Map function in Python

In this tutorial, we will understand what the map function in Python is meant. Further, we will see the syntax to be used for the same in python language. We...

3 minutes read.

Important Difference between Python 2.x and Python 3.x with Example

The comparison between Python 2 and Python 3 is given in the article that follows. Python is a computer language that can perform more tasks than other languages and is...

5 minutes read.

Python 2.7 data structures

The rundown information type has a few additional techniques. Here is every one of the strategies for listing objects: list.append(x): Add a thing to the furthest limit of the rundown; comparable...

9 minutes read.

Flutter Python

The flutter is a frame work available in the python programming language, to create web applications, mobile apps. The flutter is generally used for the development of the backend of...

3 minutes read.

Python Pascal Triangle

Python Pascal Triangle Pascal triangle A pascal triangle is a number pattern of triangular array of the binomial coefficients. For designing a pascal triangle, we write a function in the program which...

5 minutes read.

Palindrome In Python

What is Palindrome? A Palindrome can be defined as the number or a string that resides unchanged when it is reversed. Example: 14341 Output: Yes, this is a Palindrome number Example: RACECAR Output: Yes, this...

2 minutes read.

Insertion Sort using Python

Insertion sort is a type of sorting technique that is used for sorting an array with random elements. Using sorting methods, any unsorted array can be sorted into ascending or...

3 minutes read.

Genetic Algorithm in python

Python : Python is an object oriented programming language which is highly interpreted and is highly interactive. Python was created by Guido van Rossum in the year 1985 – 1990 .The source...

4 minutes read.

Python Virtual Environment

In this tutorial, we will understand Virtual Environment in Python. We will understand the need for a virtual environment and also see how to make use of it in python....

3 minutes read.

NOT IN operator in Python

This page contains all the information about “not in” operator in python. You can also know everything about what type of operator is “not in” in python language and where...

7 minutes read.

GET and POST requests using Python

‘GET’ and ‘POST’ are two request methods of Hypertext Transfer Protocol (HTTP). What is HTTP? HTTP stands for Hypertext Transfer Protocol. It is a collection of protocols which makes communication between client...

4 minutes read.

How to Iterate a List in Python

As we know, a List is one of the four unique data structures available in Python; in this article, we will deep dive into understanding iterating through a list and...

3 minutes read.

How to create a list in Python?

How to create a list in python Python is known for its versatility and its data structures help us to perform different kinds of operations on various datasets irrespective of their...

4 minutes read.

Python IDE

What is an IDE?  An IDE or an Integrated Development Environment is a type of software where developers can develop many software’s and applications and run the programs inside it. An...

11 minutes read.

Python Logging Maxbytes

Python: Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

6 minutes read.

Program of Cumulative Sum in Python

Introduction This tutorial, explains what is meant by lists, the cumulative total, several approaches to calculating the cumulative sum of digits in a list, etc. Learn the straightforward Python codes for...

5 minutes read.