
Stephen D. answered 10/21/20
Software Engineer Specializing in C++
There are a few different components to this problem that are important to understand:
The biggest are while loops, if statements, and dictionaries.
If you need a walkthrough, I solved this for you in real time on video: https://youtu.be/3Kc_RD-7Jns
Create an empty dictionary a variable named song search:
Repeatedly prompt the user to enter either the title of a song or enter nothing if they have no more songs to enter. For each song title entered by the user, split the song title into words by using the split function and splitting on a space. For each word from each song title, ensure the song_search dictionary has an entry with that word as the key and a list (initially empty) as the value.
Once the user has finished entering song titles, repeatedly ask the user if they want to look up a song by keyword until they say no. If they respond yes prompt them for a keyword and print all the song titles containing that word by looking up the value in the song_search dictionary using the keyword as the key.
If the keyword the user entered is more than one song title, print each song title on a separate line proceeded by a number beginning with one and increasing by one for each song.
If the keyword the user entered is in none of the song titles, print the message Keyword not found in any song titles
Stephen D.
This response does not correctly reflect the question.10/22/20