# Python Program to Count Number of Lowercase Characters in a String

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

When it is required to count the number of lowercase characters in a string, the string can be iterated over. It can be checked to see if it has lower case characters, and the counter can be incremented.

Below is the demonstration of the same −

## Example

Live Demo

my_string = "Hi there how are you"
print("The string is :")
print(my_string)
my_counter=0
for i in my_string:
if(i.islower()):
my_counter=my_counter+1
print("The number of lowercase characters are :")
print(my_counter)

## Output

The string is :
Hi there how are you
The number of lowercase characters are :
15

## Explanation

• A string is defined, and is displayed on the console.

• A counter is initialized to 0.

• The string is iterated over.

• It is checked to see if it is lower case.

• If it is lower case, the counter is incremented.

• This is the output that is displayed on the console.

Updated on 16-Apr-2021 12:37:52