19/19 review built in functions


Why isn't this working?

19:19 pdf.pdf (26.7 KB)


Could you post your code rather than creating a pdf?


def distance_from_zero(num):
return type(num)

if type(num) == int:
    return abs(num)
elif type(num) == float:
    return abs(num)
    return "Nope"

print distance_from_zero(-3)


@cduplantier You are asking the function to return the type of num which is unnecessayr. If you take out that bit of code:

then it should work. Otherwise use mine:

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

Let me know if you need more help after that. :slight_smile: Hope it works!


Thanks! That worked!


good you know :slight_smile:


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