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
Larz60+ write Oct-27-2020, 04:18 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time