My homework assignment is to Write a program that reads a string from the user and creates a list of words from the input.Create two lists, one containing the words that con
You can use List Comprehensions to get all upper case characters and lower case characters.
def get_all_cap_lowercase_list(inputStr):
cap_temp_list = [c for c in inputStr if c.isupper()]
low_temp_list = [c for c in inputStr if c.islower()]
print("List of Cap {0} and List of Lower {1}".format(cap_temp_list,low_temp_list))
upper_case_count = len(cap_temp_list)
lower_case_count = len(low_temp_list)
print("Count of Cap {0} and Count of Lower {1}".format(upper_case_count,lower_case_count))
get_all_cap_lowercase_list("Hi This is demo Python program")
And The output is:
List of Cap ['H', 'T', 'P'] and List of Lower ['i', 'h', 'i', 's', 'i', 's', 'd', 'e', 'm', 'o', 'y', 't', 'h', 'o', 'n', 'p', 'r', 'o', 'g', 'r', 'a', 'm']
Count of Cap 3 and Count of Lower 22