Review: Built-In Functions


#1



https://www.codecademy.com/en/courses/python-beginner-c7VZg/4/3?curriculum_id=4f89dab3d788890003000096


Traceback (most recent call last):
File "python/cli_runner.py", line 152, in


I was stuck at this exercise and cannot proceed to the next.
However, I don't know what's wrong with my script.


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


#2

Interesting...I passed this lesson a long time ago. I went back to it and ran my code. Error pops up for me too.

I did this to pass it again (though it only works one time):
I switched browsers from Chrome -> IE. Ran my code there and it passed. If I ran it the second time, I get the error.
Your code itself looks fine.


#3

Nothing is wrong with the code, maybe just a ghost in the machine, so to speak. I was able to replicate the problem by doing a copy/paste of your code and get past it by erasing the code and re-typing it in by hand.


#4

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