So I am answering this question in a challenge that I am currently participating in
Question: Keeping up with the best streamers is hard, so you decide to ask your friends for subscription recommendations. Write a program to help track the streamers to watch. Your program should ask for a friend's name and a streamer they recommend, until 5 different streams are suggested. Each stream cannot be recommended more than once. Once 5 different streams have been suggested, it should print the list of streams and the friends who recommended them.
Note: Friends are allowed to recommend more than one stream.
if someone suggests a stream that has already been recommended. The program prints: Someone else already recommended that.
Here's what I have:
playlist = {}
while len(playlist) < 5:
name = input('Friend: ')
stream = input('Which stream did they recommend? ')
print (f'{name} recommended {stream}!')
playlist[name] = stream
if stream in playlist:
playlist = playlist + ""
else:
playlist = playlist + stream
print('Playlist complete! Subscribe to:')
for name, stream in playlist.items():
print(f'{stream}: recommended by {name}')
I wanna check if the same stream has been recommended twice and print someone else already recommended that
here's how the output should look: