The title ^. For some reason the code I have now is allowing words to slip through that evidently don't contain the required letters.
listOfValid = ["xxxxy", "xxxxz", "xxxxx", "a", "ab"]
lettersIn = ["a", "b"]
for word in listOfValid:
for letter in lettersIn:
if letter not in word and word in listOfValid:
listOfValid.remove(word)
print(listOfValid)
This returns: 'xxxxz' 'a' 'ab'. Why is it allowing xxxxz and a through?