I'm trying to filter a list of words/phrases by some keyword. All the examples I've found of the filter() function have been using numbers, so I'm wondering if this is even possible. I know that filter() will put an item into the resulting list if the function it calls returns True.
Let's say I have something like this:
def filtCheck(item, filt):
if filt in item:
return True
def funct():
filt = 'Hi'
set1 = ['Hello, world', 'Hi there', 'Hi friend']
set2 = filter(filtCheck(filt), set1)
print set2
Here is where I get confused. How exactly would I write that first parameter on the set2 line? Obviously not the way its written since my filtCheck function takes two parameters and I only provide one. Do I need to modify my filtCheck function too? But if I take the item parameter out of it, there's no string to check if filt is in.