I have a text file with this information:
1961 - Roger (Male)
1962 - Roger (Male)
1963 - Roger (Male)
1963 - Jessica (Female)
1964 - Jessica (Female)
1965 - Jessica (Female)
1966 - Jessica (Female)
If I want to search for the word "Roger" in the file, I want it to print out the corresponding years for that name, that is 1961, 1962, 1963. What would be the best way to approach this?
I was doing it with a dictionary but then realized later that dictionaries can't have duplicate values and 1963 is mentioned twice in the text file so it didn't work.
I'm using Python 3, thanks.