3 ms·
How about >>> lyrics_list = ["her", "name", "is", "rio"] >>> words = ["is", "rio"] >>> print '\n'.join("{} is in the lyrics".format(word) for word in set
by MattConfluence 12y ago
How about
>>> 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 lyrics
- LyndsySimon 12y agoHeh, I just replied with pretty much this exact code to someone else trying to make it a one-liner. Yes, it's possible. I would never, ever publish code like this, though. It's opaque.