Trying to clean up a python list, I am able to remove exact string matches. How do I remove partial matches?
exclude = ['\n','Hits','Sites','blah','blah2','partial string','maybe here']
newlist = []
for item in array:
if item not in exclude:
newlist.append(item)
Problem here is “item not in exclude”… which does exact matching.
Should I use the following method:
s = "This be a string"
if s.find("is") == -1:
print "No 'is' here!"
else:
print "Found 'is' in the string."
In a way i answered my own question 🙂 I guess is there an operand alternative to ‘in’ ?
Thanks
Is this what you are searching for?