Review: Built-In Functions --Getting an error message


#1



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


I'm getting this error message at the bottom: Oops, try again. Your function seems to fail on input True when it returned '1' instead of 'Nope'


I feel this function should work.


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

print distance_from_zero(-25)


#2

We need to carry out the same comparison for both operands of the OR expression.

if ... == int or ... == float

#3

its also getting error msg


#4

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