Slip 2 - A) Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String: 'The quick Brown Fox' Expected Output: No. of Upper case characters: 3 No. of Lower case characters: 13

Solution:


def countcase(str):
    upper,lower=0,0
    for i in str:
        if(i.isupper()==True):
            upper+=1
        elif(i.islower()==True):
            lower+=1
    print(" No. of Upper case characters: ",upper)
    print(" No. of Lower case characters: ",lower)
#Tgts
str=input("Enter string: ")
countcase(str)

Output:

Output_pic


Post a Comment

0 Comments