Review: Built-In Functions


#1


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

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

help me plez

Replace this line with your code. 

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


#2

What do you mean by

return abs

?

Also check your indentation.

No idea why this would return '1' though.


#3

my code is

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


#4

abs() is a method, it needs parentheses, and the directions tell us that if the number fit the if statement, return the absolute value of the number so the line I pointed out should be like this:

return abs(num)

#5

thanks for your help


#6

Did it work? And you're welcome.


#7

yeah it worked out for me


#8

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