19. Review: Built in Functions


#1

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' ?


#2

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


#3

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' ?


#4

Hi @amydav,

You have this line after the function header ...

    return type(num)

What is the purpose of that line?


#5

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