4 ms·
Even shorter, nice. How about this one liner, the last bit is looking a bit messy any ideas? print " is in the lyrics \n".join([set(lyrics_list) & set(word
by parham 12y ago
Even shorter, nice. How about this one liner, the last bit is looking a bit messy any ideas?
print " is in the lyrics \n".join([set(lyrics_list) & set(words)]), "is in the lyrics"
- MattConfluence 12y agoHow 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.
- LyndsySimon 12y agoJust because it can be written as a one-liner doesn't mean it should be written as a one-liner :) Don't ever do this. print('\n'.join(['{} is in the lyrics'.format(word)) for word in (set(lyrics_list) & set(words))])
- parham 12y agoI never said it should, it was a challenge.