mentalCase mentalCase - 2 months ago 7x
Python Question

Syntax error at second definition in Python

def specificChecker(someThing, checker):
if checker == None:
return someThing
elif checker == True:
return not someThing
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.'
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?


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