19. Review: Built-in function problem


#1

Hey guys I'm not sure what I've done wrong as it looks like everyone else's I've looked at

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

Indents are all there, don't know why they dont show up in the post

Error I'm getting is:
Oops, try again. Your function seems to fail on input -10 when it returned 'Nope' instead of '10'


#2

should it be

if type(n) == int or type(n) == float:

??


#3

Ah you're right! Silly me


#4

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