i want to find the intersection of two lists in python. i have something that looks like this:
>>> q = ['apple', 'peach', 'pear', 'watermelon', 'strawberry']
>>> w = ['pineapple', 'peach', 'watermelon', 'kiwi']
and i want to find something that looks like this:
t = ['peach', 'watermelon']
i know its a simple, question but im new to python–does anyone have any suggestions?
The intersection() method is available for sets, which can be easily made from lists.
ETA: if you want a list out of it…
Now t is: