Dont get this error message!


#1

code:

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

error message:

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

What does it mean?!?!


#2

@dan_john,

def distance_from_zero(num):
    print type(num)
    if type(num) is int or type(num) is float:
        return abs(num)
    else:
        return num

reference:

google search
== discussions / opinions ==
python testing for type() site:stackoverflow.com