← 2023 questions

2023 / SPOTIFY / QUESTION 10

Unique playlists

Try the question in your own editor, then check your output below.

THE QUESTION

Vignesh likes his playlists to all be unique. But sometimes Vignesh accidentally adds the same song to different playlists. Program a function that does the following:

asks the user to input a song from the list

outputs the amount of times the song appears from all 3 playlists

returns and outputs True if the track is exclusively in one playlist

returns and outputs False if the track is in multiple playlists

Run this code for two song inputs

Bad habit by Steve Lacy

Solo by Future

(Remember to screenshot outputs for both songs)

Starter code:

playlist1 = ["Solo by Future", "After Dark by Mr.Kitty","Those Eyes by New West","Golden Hour by JVKE","505 by Arctic Monkeys"]
playlist2 = ["No Surprises by Radiohead", "Viva La Vida by Coldplay","Woo by Rihanna", "Bad habit by Steve Lacy", "Hope by NF"]
playlist3 = ["Glue Song by beabadoobee", "About You by 1975","Nonsense by Sabrina Carpenter", "Bad habit by Steve Lacy", "Midnight Rain by Taylor Swift"]
song = input("What song do you want to check? ")
num_of_appears = 0

Question by Elena. Source: Girls In Code SEA — Behind the Screens, 2023, slide 25.

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Enter the occurrence count followed by True or False.

Enter the occurrence count followed by True or False.

Reveal worked answer

Bad habit by Steve Lacy

2 False

Solo by Future

1 True

Bad habit appears in playlists 2 and 3. Solo appears only in playlist 1.