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
You can make use of sets:
>>> l = ['aba', 'acba', 'caz'] >>> s = set('abc') >>> [item for item in l if not set(item).difference(s)] ['aba', 'acba']