I have a a user-inputted polynomial and I only want to use it if it only has characters in the string 1234567890^-+x
.
How can I check if it does or not without using external packages? I only want to use built-in Python 2.5 functions.
I am writing a program that runs on any Mac without needing external packages.
Here are some odd ;-) ways to do it:
good = set('1234567890^-+x')
if set(input_string) <= good:
# it's good
else:
# it's bad
or
if input_string.strip('1234567890^-+x'):
# it's bad!
else:
# it's good