I am well aware that you can do a one line if else
statement in Python, but I am wondering if it is possible to add an or
to that. For some reason this does not work, even though it reads like it should. Is there any way to do this:
def write(value):
return 'That is not a good value' if value is not 1 or 0 #SyntaxError: invalid syntax
EDIT
So that this function would check if the passed in value was the integer 0 or 1, return 'That is not a good value'
if it is not, or not return anything if it is. I.E.
write(1) #Nothing
write(2) # That is not a good value