Skip to content

Instantly share code, notes, and snippets.

@AnisahTiaraPratiwi
Created March 23, 2021 07:57
Show Gist options
  • Save AnisahTiaraPratiwi/79e6d23ca7fd6effca6e21104a9f835d to your computer and use it in GitHub Desktop.
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…
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