Created
March 23, 2021 07:57
-
-
Save AnisahTiaraPratiwi/79e6d23ca7fd6effca6e21104a9f835d to your computer and use it in GitHub Desktop.
In Python, a dictionary can only hold a single value for a given key. To workaround this, our single value can be a list containing multiple values. Here we have a dictionary called "wardrobe" with items of clothing and their colors. Fill in the blanks to print a line for each item of clothing with each color, for example: "red shirt", "blue shi…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wardrobe = {"shirt":["red","blue","white"], "jeans":["blue","black"]} | |
for item, colors in wardrobe.items(): | |
for color in colors: | |
print("{} {}".format(color, item)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment