Oops, try again. Your function seems to fail on input -10 when it returned 'None' instead of '10'


#1



Hi
Oops, try again. Your function seems to fail on input -10 when it returned 'None' instead of '10'

why I am getting above error message Instead returning absolute value


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


#2

Your indentation is way off, so your if and else are outside of the function.


#3

This should work

def distance_from_zero(num):
    result = (type(num) == int or type(num) == float)
    if result == True:
        return abs(num)

    else:
        return "Not a number!"