Review: built in functions


#1



Oops, try again. Your function seems to fail on input -10 when it returned 'nope' instead of '10'


^^ that is my error message and I dont know how to fix it


def distance_from_zero(a):
    if a == type(12) or a == type(12.1):
        return abs(a)
    else:
        return "nope"


#2

We need to take the type of input and compare to fixed types, int and float.

type (a) ...

#3

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