In Python I am trying to create a list (myClassifier) that appends a classification ('bad'/'good') for each text file (txtEntry) stored in a list (txtList), based on whether or not it contains a bad word stored in a list of bad words (badWord).
txtList = ['mywords.txt', 'apple.txt, 'banana.txt', ... , 'something.txt']
badWord = ['pie', 'vegetable, 'fatigue', ... , 'something']
txtEntry is merely a placeholder, really I just want to iterate through every entry in txtList.
I've produced the following code in response:
for txtEntry in txtList:
if badWord in txtEntry:
myClassifier += 'bad'
else:
myClassifier += 'good'
However I'm receiving TypeError: 'in ' requires string as left operand, not list as a result.
I'm guessing that badWord needs to be a string as opposed to a list, though I'm not sure how I can get this to work otherwise.
How could I otherwise accomplish this?