19. Review: Built-In Functions Help


Hey guys! Was wondering if anyone could give me a hand with this one, I've been stuck here for a while:

Here is my code:

def distance_from_zero(n):
if type(n) == int or type(n) == float:
    return abs(n)
    return "Nope"

I'm getting this error message and I'm not sure how to fix it:

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

This is the error that's coming up in the console:

File "python", line 2
if type(n) == int or type(n) == float:
IndentationError: expected an indented block

Any help would be MUCH appreciated, thank you.


to nest an if condition inside the function you are going to need to indent it:

def example():
   if True:
      print True


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.