19 review built in functions


#1

Hello,

I'm stuck on the review of this last section, this is my code:

def distance_from_zero(stac):

if type(stac) == int:
    return distance_from_zero(abs)

elif type(stac) == float:
    return distance_from_zero(abs)
else:
    return "nope"

it is suppose to determine if the argument is a float or a integer and if it is return the absolute value. can anyone tell me what's wrong? thanks in advance!


#2

There are two things that are causing you issues.

First, abs() is a built in function that we call and pass a number to. In this case we want to pass the input of distance_from_zero, which is stac. Your return statement should be return abs(stac).

That brings us to the second issue. Currently you are returning distance_from_zero(abs), which is basically calling your function and passing abs as input. That is not what you want to be doing.


#3

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