So this is a smaller version of my sentences/phrase list:
search = ['More than words', 'this way', 'go round', 'the same', 'end With', 'be sure', 'care for', 'see you in hell', 'see you', 'according to', 'they say', 'to go', 'stay with', 'Golf pro', 'Country Club']
What I would like to do is remove any terms that are more or less than 2 words in length. I basically just want another list with all 2 word terms. Is there a way to do this in Python? From my searching, I have only managed to find how to erase words of a certain number of characters and not entire phrases.
You can get 2 word phrases using this:
ans = list(filter(lambda s: len(s.split()) == 2, search))
Another way is using list comprehension:
ans = [w for w in search if len(w.split()) == 2]
As OP asked for removing duplicates in comment, adding it here:
ans = list(set(filter(lambda s: len(s.split()) == 2, search)))