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:
Original String : TechStudy - The Complete Debugging Solution
No. of Upper case characters : 6
No. of Lower case Characters : 31
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used python 3.7 compiler for debugging purpose.
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