Review: Built-In Functions


#1

this is my code:

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

else: 
    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


#2

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.


#3

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