Looking for answers? Westonci.ca is your go-to Q&A platform, offering quick, trustworthy responses from a community of experts. Get quick and reliable answers to your questions from a dedicated community of professionals on our platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

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