Review: Built In Functions - Works fine in


Hey everyone,

Can anyone see what the issue is with this code? It seems to run find in when I call the function with either an int, float or a string.

Give me an "Oops, try again. Your function seems to fail on input True when it returned '1' instead of 'Nope'"

def distance_to_zero(n):
    if type(n) == int or type(n) == float:
        return abs(n)
        return 'Nope'



Well first off, instructions 1.) says, "First, def a function called distance_from_zero," and I changed mine to distance to zero and it came back with name errors. Might not be your main problem but you will need to change that. And honestly other than that your code looks good.


Bah! Why is it always something that easy? Thanks for the second set of eyes!


Haha no problem! that is why we are here to help out the weary souls of coders :stuck_out_tongue:


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