Oct-27-2020, 03:00 PM
Hi everyone. I ran into a problem. I would like words in the dictionary that are written in lowercase to be displayed in uppercase. I thought I found a solution but it only works with a list.
How to write a function and where, to have carrots, thyme and other products written with capital letters? Greetings
shopping = { "bakery": ["bread","doughnut", "cake",], "grocery": ["carrot","pear", "thyme"] } for i in shopping: print(i, shopping[i])A function which i found that unfortunately does not work in the dictionary. Example for a list:
my_list = ["bread", "butter"] my_list = [element.capitalize()for element in my_list] print(my_list)And this is good
How to write a function and where, to have carrots, thyme and other products written with capital letters? Greetings