Skip to content

Instantly share code, notes, and snippets.

@richardpascual
Last active August 24, 2021 21:31
Show Gist options
  • Save richardpascual/12a71c18527366415099b064ed2e61e5 to your computer and use it in GitHub Desktop.
Save richardpascual/12a71c18527366415099b064ed2e61e5 to your computer and use it in GitHub Desktop.
# Example 1
drinks = ["espresso", "chai", "decaf", "drip"]
caffeine = [64, 40, 0, 120]
zipped_drinks = zip(drinks, caffeine)
drinks_to_caffeine = {key:value for key, value in zipped_drinks}
print(drinks_to_caffeine)
# Codecademy
# Example 2
songs = ["Like a Rolling Stone", "Satisfaction", "Imagine", "What's Going On", "Respect", "Good Vibrations"]
playcounts = [78, 29, 44, 21, 89, 5]
plays = {key:value for key, value in zip(songs, playcounts)}
print(plays)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment