19.review built in functions


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

this is showing an error and i dont understand what is wrong!!


I had the same issue. After the error, I used this code:

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

I called type(n) before the if statement. After I did this, it worked.


print "Nope should be print "Nope".

P.S. Please format your code. Thanks!


You should not need to call type(n) like that in a single statement by itself. Your code should work fine without it.


@julesrck Thnx a lot for this one! :relaxed: