
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Count Number of Lowercase Characters in a String in Python Program
When it is required to count the number of lower case characters in a string, the ‘islower’ method and a simple ‘for’ loop can be used.
Below is the demonstration of the same −
Example
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 in the string are :") print(my_counter)
Output
The string is Hi there how are you The number of lowercase characters in the string are : 15
Explanation
A string is defined and is displayed on the console.
A counter value is initialized to 0.
The string is iterated over, and checked to see if it contains lower case alphabets using the ‘islower’ method.
If so, the counter is incremented by 1 until the end of the string.
This is displayed as output on the console.
- Related Articles
- Python Program to Count Number of Lowercase Characters in a String
- Program to count number of distinct characters of every substring of a string in Python
- Count the Number of matching characters in a pair of string in Python
- Program to check string is palindrome with lowercase characters or not in Python
- Program to count number of unique palindromes we can make using string characters in Python
- Program to count number of characters in each bracket depth in Python
- Count the Number of matching characters in a pair of Java string
- How to count the number characters in a Java string?
- Python program to count number of substring present in string
- Python program to count the number of spaces in string
- How to count the number of repeated characters in a Golang String?
- Program to count number of palindromes of size k can be formed from the given string characters in Python
- Java program to find the percentage of uppercase, lowercase, digits and special characters in a String
- Python program to convert a string into lowercase
- Python program to count number of vowels using set in a given string

Advertisements