I’m trying to weed out strings that contains "msi" using regular expressions and a list comprehension. However, when I print the list, strings that contain "msi" are still in the list. What exactly would the error be? This is my code:
spam_list = [l for l in spam_list if not re.match("msi", l)]
re.match()matches from the beginning of the string. Usere.search(), or even better,in.