In my code, I have two lists, of different lenghts, which I'll call "main" and "secondary". I need to use elements in secondary to select elements in main. However, secondary contains elements that are just sub-sets of the strings in main. In code:
main = ["pinecone", "treeleaf", "dishwasher"]
secondary = ["pine", "washer", "unrelated", "flowerbed"]
Usually secondary is much longer than main (I mention this in case solutions involve performance penalties). How do I go and select elements in "main" basing on "secondary" with the most efficient (and Pythonic) way possible? If it were a function, I'd expect
>>> selected_items = select_items(main, secondary)
>>> print selected_items
["pinecone", "dishwasher"]
Thanks!