Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters

Introduction

Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. I have used python 3.7 compiler for debugging purpose.

def string_test(str):
    d={"UPPER_CASE":0, "LOWER_CASE":0}
    for c in str:
        if c.isupper():
           d["UPPER_CASE"]+=1
        elif c.islower():
           d["LOWER_CASE"]+=1
        else:
           pass
    print ("Original String : ", str)
    print ("No. of Upper case characters : ", d["UPPER_CASE"])
    print ("No. of Lower case Characters : ", d["LOWER_CASE"])
 
string_test('TechStudy - The Complete Debugging Solution')

Result

Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters
Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters

Leave a Comment

x