Review: Built-In Functions


this is my code:

def distance_from_zero(badadada):
    if type(badadada) == int or type(badadada) == float:
        return abs(badadada)

    return "Nope"

it says:
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

someone help. i am so confused


I know you are just fooling around, but it will be well to use sensible variable names in the future. Tell the reader what it is, literally.

def distance_from_zero(number):

The else is outside of the code block of the function and is raising a syntax error.


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