Review: Built-In Functions


#1



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


It always returns "Nope". I believe my code is correct!


def distance_from_zero (arg):
    if type(arg) == int or type(arg)==float:
        return abs(arg)
    else:
        return "Nope"    
    
print distance_from_zero("-2415812")


#2

print distance_from_zero("-2415812")

this line not need.
but your problem is this: type("-2415812") is an string, not int, not float. because you use "" around that.


#3

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