Counting number of upper case and lower case characters in a given string – python lab program

This program uses “for” loop to process the string.

islower() and isupper() functions are used to check whether the current character of the string is in lower case or in upper case.

s=input("Enter the String")
u=int(0)
l=int(0)
for a in s:
     if((a.islower())==1):
           l=l+1
     elif((a.isupper())==1):
           u=u+1
print("The number of Upper Case Letters is ",u)
print("The number of Lower Case Letters is ",l)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.