19. Review: Built in Functions


def distance_from_zero(num):
return type(num)

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

Why doesn't this fail on input -10 when it returned '' instead of '10' ?


Just tested your code myself, it works fine. What do you mean by,


When I try to run the code, it says that it is incorrect because
it fails on input -10 when it returned '' instead of '10' ?


Hi @amydav,

You have this line after the function header ...

    return type(num)

What is the purpose of that line?


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