Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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:

Original String :  TechStudy - The Complete Debugging Solution

No. of Upper case characters :  6

No. of Lower case Characters :  31

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Python function that takes a list and retu... >>
<< Write a Python function to check whether a number ...