Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Join our platform to connect with experts ready to provide accurate answers to your questions in various fields. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.

Create a function that returns a dictionary containing the number of upper and lower case characters in a string (e.g. {'lower': 8, 'upper': 2}). Ignore whitespace characters. Your function should be able to handle an empty string, though.

Sagot :

Answer:

Explanation:

The following is written in Python and takes in the input string, then loops through it counting all of the upper and lower case letters and adds it to the dictionary.

string = input("input string: ")

upper_case = 0

lower_case = 0

for char in string:

   if char.isupper() == True:

       upper_case += 1

   elif char == ' ':

       pass

   else:

       lower_case += 1

letter_dict = {'upper_case': upper_case, 'lower_case': lower_case}

View image sandlee09
Thank you for your visit. We are dedicated to helping you find the information you need, whenever you need it. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.