0
def specificChecker(someThing, checker):
    if checker == None:
        return someThing
    elif checker == True:
        return not someThing
    else:
        return None

def whatDoesTheCheckerSay(someThing):
    if specificChecker(someThing) == someThing:
        return 'The checker value was False on that one.'
    elif specificChecker(someThing) == not someThing:
        return 'The checker value was True on that one.'
    elif specificChecker(someThing) == None:
        return 'Something irregular happend. The checker value wasn\'t None or True.'
    else:
        return 'Something went really wrong. This doesn\'t even not work.'

reallySomeThing = input('Type in really some thing: ')
theChecker = input('Set the checker to something: ')

print(specificChecker(reallySomeThing, theChecker))
print(whatDoesTheCheckerSay(reallySomeThing)) # This can be made more efficient, right?

def one(someShit):
    return someShit + ' AWWW YEAH!'

def two(someShit):
    return one(someShit)

print(two(input('Type in some kind of stuff: ')))

I'm a self-taught beginner, so surely it's something awkwardly basic. I'm using the IDLE shell and have repeatedly gotten a syntax error at the second definition statement of my codes. Please help?

2
  • 2
    its the == not something, it should be != something or is not something Commented Jun 23, 2016 at 13:02
  • 1
    @nbryans: Really bad idea to mention is and just say "similar to ==". is means identity testing; x is y only if x and y are references to the exact same object. In general, you only use is with language specified singletons (None, NotImplemented, Ellipsis, but not True/False, even though they're singletons, PEP8 recommends implicit truth testing for good reasons), types (if you want an instance of a specific class, but not subclasses thereof, type(obj) is MyClass), and sentinels (sentinel = object(); val = mydict.get(key, sentinel); if val is not sentinel:). Commented Jun 23, 2016 at 15:20

2 Answers 2

4

You cannot use the line:

elif specificChecker(someThing) == not someThing:

This must be written

elif specificChecker(someThing) != someThing:

to be valid Python.

This is also valid but is perhaps less readable:

elif (specificChecker(someThing)) == (not someThing):

After OP edit:

The new error is the mismatch in arguments (always 1) to a function that requires 2 arguments. You have to pass two arguments to specificChecker not one

Sign up to request clarification or add additional context in comments.

3 Comments

I have been using Python for many years and never knew that. Is it documented somewhere that == not is a SyntaxError?
The == comes before not in the operators so I assume takes precedence.
2

Line 12: elif specificChecker(someThing) == not someThing:

If you want to check if some variable is not some variable, used is not for boolean or != for values and strings

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.