How Count Lowercase Letters in Python

In this tutorial, we’ll learn how to program "How to Count Lowercase Letters in Python." The objective is to accurately count all the lowercase letters present in a string. This tutorial will guide you through the process step by step on how to handle the counting of lowercase letters. By the end, you’ll have a clear understanding of how to efficiently perform this task in Python.

This topic is straightforward to understand. Just follow the instructions I provide, and you’ll complete it with ease. The program I’ll demonstrate will show you the correct and efficient way to count all the lowercase letters. So, let’s dive into the coding process!

Getting Started:

First you will have to download & install the Python IDLE's, here's the link for the Integrated Development And Learning Environment for Python https://www.python.org/downloads/.

Creating Main Function

This is the main function of the application. The following code will display a simple GUI in terminal console that will display program. To do this, simply copy and paste these blocks of code into the IDLE text editor.
  1. while True:
  2.       print("\n============= Count Lowercase Letters =============\n")
  3.       my_string=input("Enter a string: ")
  4.       count=0
  5.       for i in my_string:
  6.             if(i.islower()):
  7.                   count=count+1
  8.       print("\nThe number of lowercase letter is: ", count)
  9.  
  10.      
  11.       opt = input("\nDo you want to try again?(yes/no): ")
  12.        
  13.       if opt.lower() == 'yes':
  14.             ret=False
  15.       elif opt.lower() == 'no':
  16.             ret=True
  17.             print("Exiting program....")
  18.       else:
  19.             print("Please enter yes/no:")
  20.             break
  21.  
  22.       if ret == False:
  23.             continue

This program counts the number of lowercase letters in a user-provided string by iterating through each character and checking if it's a lowercase letter, then displays the result and repeats the process until the user chooses to exit.

Output:

There you have it we successfully created How Count Lowercase Letters in Python. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!

More Tutorials for Python Language

Python Tutorials

Add new comment