I have a a user-inputted polynomial and I only want to use it if it only has characters in the string 1234567890^-+x.
1234567890^-+x
How can I check if it does or not
What about just convert both the string into set and checking input_set is subset of good_set as below:
input_set is subset of good_set
>>> good_set = set('1234567890^-+x') >>> input_set1 = set('xajfb123') >>> input_set2 = set('122-32+x') >>> input_set1.issubset(good_set) False >>> input_set2.issubset(good_set) True >>>