There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
This is another solution for the 2nd checkpoint. It’s quite lengthy
for song, tag in song_data.items():
if len(set(tags_int) & set(tag)) != 0 and song not in user_recent_songs:
recommended_songs[song] = tag
for tag in tags_int:
for key, values in song_data.items():
if tag in values and key not in user_recent_songs.keys():
recommended_songs[key] = values
This loop adds songs to recommended_songs if they have EITHER of the two tags, if anyone is interested. Test it out by adding:
‘Just The Synth’: [‘synth’, ‘and’, ‘some’, ‘other’, ‘tags’], ‘Just Electronic’: [‘electronic’, ‘and’, ‘some’, ‘other’, ‘tags’]
To the song_data dictionary.
Not the most efficient way but I ended up using nested for loops.
for song in song_data:
print("printing", song)
for tag in song_data[song]:
print("printing tag", tag)
if tag in tags_int:
print("printing tag in tags_int", tag)
if song not in user_recent_songs:
recommended_songs[song] = tag
^^ still cleared step 2. But when I took a look at the solution and ran that code I got a different answer when I printed out the recommended songs.
This is an awesome solution! I was a bit puzzled at first because nowhere in the course mentioned that empty sets are falsy in a Boolean context. Great find!