19. Review: Built-in function problem


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)
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'


should it be

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



Ah you're right! Silly me


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