7.Functions 19. Review:Built-In Function


#1



Need some help guys.Tips?

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


#2

Why do you have "type" in there?


#3

removed type still getting error message

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

Oops, try again. It looks like you have a NameError. Maybe you forgot to create a function called distance_from_zero? Check the error message for more info! - global name 'distance_from_zero' is not defined


#4

jk "type"'s suppose to be there. I'm just being a noob XD

Are you sure you're indenting correctly? I pasted your original code in my console and it worked.

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

Sorry if that sounds like a dumb thing to ask you to check. I know asking about the indention's basically the equivalent of tech support asking if you turned it on and off again but python's picky about white space.


#5

Not at all. That was it. My indentation was off. Thanks gh !


#6

No prob @improviser14. Glad to help :smiley: <--Creepy smiley face