I’d like to determine if a string can be created using only characters in a list. For example,
>>>acceptableChars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
>>>print isAcceptable("abc")
True
>>>print isAcceptable("xyz")
False
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Make a set from
acceptableChars:Now we can make isAcceptable check if any of the characters in its argument are not in
acceptableCharsusing set subtraction: