Python: Test if string ONLY contains given characters
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 a list of stings, and I want to filter out all of
them except the words that are ONLY made up of ANY of the letters in
another string. For example, filtering ['aba', 'acba', 'caz'] though 'abc'
should give ['aba', 'acba']. (z not in abc)
Just like only keeping the items that can be made using the given letters.
Thanks!
No comments:
Post a Comment