19. Review: Built-In Functions fails on input -10


#1

Hello There,

I am getting the following error:
Your function seems to fail on input -10 when it returned ‘Nope’ instead of ‘10’

I run out of ideas. My code is:

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

Do you have any clue what’s wrong?

Thanks


#2

We do not want to compare to a function, but a class.

... == int

#3

Brilliant, thank you!


#4

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