Home >>Python Programs >Python program to find total number of uppercase and lowercase letters
In this example, we will see a Python program through which we can find the total number of uppercase and lowercase letters present in a given input string.
In this Python program either we can use a loop and check each character of the string with a range of uppercase and lowercase letters or we can use :-
islower() and isupper() methods.Program 1:
print("Input a string: ")
str1 = input()
no_of_ucase, no_of_lcase = 0,0
for c in str1:
if c>='A' and c<='Z':
no_of_ucase += 1
if c>='a' and c<='z':
no_of_lcase += 1
print("Input string is: ", str1)
print("Total number of uppercase letters: ", no_of_ucase)
print("Total number of lowercase letters: ", no_of_lcase)
print("Input a string: ")
str1 = input()
no_of_ucase, no_of_lcase = 0,0
for c in str1:
no_of_ucase += c.isupper()
no_of_lcase += c.islower()
print("Input string is: ", str1)
print("Total number of uppercase letters: ", no_of_ucase)
print("Total number of lowercase letters: ", no_of_lcase)