19. Review: Built-In Functions


#1

What's wrong with my code?

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

It returns > Oops, try again. Your function seems to fail on input True when it returned '1' instead of 'Nope'


#2

Maybe it's asking you to switch the outputs: to return "Nope" when it's True, and to return abs(num) when it's False.


#3

Hi @nikdj ,

Rename your function and submit it again. You have ...

def distace_from_zero(num):

Codecademy probably remembers a previous incorrect version of your function that had the correct name.


#4

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