Q. Write a Python function that accepts a string and calculate the number of uppercase letters and lowercase letters.
Sample String : PythonProgramminG
Expected Output:
Original String : PythonProgramminG
No. of Uppercase characters : 3
No. of Lowercase characters : 14
Answer =
def string_test(s):
    d = {"UPPER_CASE" : 0, "LOWER_CASE" : 0}
    for c in s:
        if c.isupper():
            d["UPPER_CASE"] += 1
        elif c.islower ():
            d["LOWER_CASE"] += 1
        else:
            pass
    print ("Original String : ", s)
    print ("No. of Uppercase characters : ", d["UPPER_CASE"])
    print ("No. of Lowercase characters : ", d["LOWER_CASE"])
sentence = input ("Enter sentence :- ")
string_test(sentence)
Output :-
Enter sentence :- PythonProgramminG
Original String :  PythonProgramminG
No. of Uppercase characters :  3
No. of Lowercase characters :  14
>>>
Enter sentence :- Path Walla, Computer Portal 
Original String :  Path Walla, Computer Portal 
No. of Uppercase characters :  4
No. of Lowercase characters :  19
>>> 
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )