This is a Python Program to count number of lowercase characters in a string.
The program takes a string and counts number of lowercase characters in a string.
1. Take a string from the user and store it in a variable.
2. Initialize a count variable to 0.
3. Use a for loop to traverse through the characters in the string and increment the count variable each time a lowercase character is encountered.
4. Print the total count of the variable.
5. Exit.
Here is source code of the Python Program to count number of lowercase characters in a string. The program output is also shown below.
string=raw_input("Enter string:") count=0 for i in string: if(i.islower()): count=count+1 print("The number of lowercase characters is:") print(count)
1. User must enter a string and store it in a variable.
2. The count variable is initialized to zero.
3. The for loop is used to traverse through the characters in the string.
4. The count is incremented each time a lowercase character is encountered.
5. The total count of lowercase characters in the string is printed.
Case 1: Enter string:Hello The number of lowercase characters is: 4 Case 2: Enter string:AbCd The number of lowercase characters is: 2
Sanfoundry Global Education & Learning Series – Python Programs.
To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.
- Check Python Books
- Practice Programming MCQs
- Apply for Programming Internship
- Check Information Technology Books
- Apply for Python Internship