- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −
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)
The string is Hi there how are you The number of lowercase characters in the string are : 15
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.
- 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
- Count the Number of matching characters in a pair of Java string
- Program to count number of characters in each bracket depth in Python
- How to count the number of repeated characters in a Golang String?
- How to count the number characters in a Java string?
- Python program to count number of substring present in string
- Java program to find the percentage of uppercase, lowercase, digits and special characters in a String
- Python program to count upper and lower case characters in a given string.
- Python Program to Calculate the Number of Words and the Number of Characters Present in a String
- Program to count number of palindromes of size k can be formed from the given string characters in Python
- Python program to count number of vowels using set in a given string