What\'s the easiest way to check if a string only contains certain specified characters in Python? (Without using RegEx or anything, of course)
Specifically, I have
Below is the code:
a = ['aba', 'acba', 'caz'] needle = 'abc' def onlyNeedle(word): for letter in word: if letter not in needle: return False return True a = filter(onlyNeedle, a) print a