Of, off the top of my head:
for word in (set(lyrics_list) & set(words)):
print('{} is in the lyrics'.format(word)) for word in (set(lyrics_list) & set(words)):
print('{} is in the lyrics'.format(word)) print " is in the lyrics \n".join([set(lyrics_list) & set(words)]), "is in the lyrics" >>> lyrics_list = ["her", "name", "is", "rio"]
>>> words = ["is", "rio"]
>>> print '\n'.join("{} is in the lyrics".format(word) for word in set(lyrics_list) & set(words))
rio is in the lyrics
is is in the lyricsYes, it's possible. I would never, ever publish code like this, though. It's opaque.
Don't ever do this.
print('\n'.join(['{} is in the lyrics'.format(word)) for word in (set(lyrics_list) & set(words))])