Need help with figuring out my code!


So here's my code:

def distance_from_zero(19):
return 19

if type(19) == int or type(19) == float:
return abs(19)

return "Nope"

The console keeps displaying this image:

File "python", line 1
def distance_from_zero(19):
SyntaxError: invalid syntax

and then tells me that my error is this:

"Oops, try again. It looks like you have a NameError. Maybe you forgot to create a function called distance_from_zero? Check the error message for more info! - global name 'distance_from_zero' is not defined"

but i honestly don't see the problem with my code at all, can someone please help?


Hi @dajadaise,

You cannot define a function by specifying a value as its parameter ...

def distance_from_zero(19):

Use a variable instead of 19 in the above function header. A variable named s might be a good idea for this exercise. Then inside the function, check the type of that variable, and proceed accordingly, instead of working with the constant, 19.

You can pass 19 or another number as a value when you call the function in a final statement...

print distance_from_zero(19)

Be sure not to indent that final statement.


Thank you so much for explaining this to me!!