Review: Built-In Functions


#1


Review: Built-In Functions

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


what's missing in my code?


def distance_from_zero(num):
    return abs(num) == int or type(num) == float:
else 
    return "Nope"


#2

You need to have an if statement that checks to make sure that the input, in this case num, is either the int type or the float type. If that is true then it should return abs(num).


#3

There should be an if statement, like this:

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

#4

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