19. Review: Built-In Functions PLEASE HELP


If someone could help that would be grand, severly stuck please help.


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

It seems as though it should work?

def distance_from_zero(r):
    if r == int or r == float:
        return abs(r)
        return "Nope"


r is just a number. How can it equal a data type (float or integer)?

use type() to get the data type of r, and compare the data type of r with integer and float data type


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