Building a playlist dictionary
With your new-found knowledge of dictionaries, you decide to translate your playlist
from a list into a dictionary! As a reminder, this is the contents of playlist
:
[1, "Blinding Lights", "The Weeknd", 2, "One Dance", "Drake",
3, "Uptown Funk", "Mark Ronson", 4, "Closer", "The Chainsmokers",
5, "One Kiss", "Calvin Harris", 6, "Mr. Brightside", "The Killers"]
The song names start at the second index "Blinding Lights"
and make up every third value afterward.
Artist names start at the third index "The Weeknd"
and also make up every third value afterward.
This exercise is part of the course
Introduction to Python for Developers
Exercise instructions
- Create a dictionary called
playlist
containing the first two songs, in that order, with artist names as keys and their respective songs as values. - Print the dictionary.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create the playlist dictionary
____
# Print the playlist
____