Def distance_by_zero(n) function (Review 7.17)


#1

def distance_from_zero(n):
if type(n) == int or type(n) == float:
print "The absolute value of the input is ", abs(n)
return abs(n)
else:
print "Not an integer or float!"
return


This is the latest code I did. I did this under Python 3.5. The problem is the error shows up as:


Oops, try again. Your function seems to fail on input True when it returned 'None' instead of 'Nope'


What is the problem here?


#2

You need to return "Nope" as they are requesting when the type of the input does not match what we are checking for


#3

Thanks, rydan.

That helped solve the problem. I finally fixed it thanks to your worded suggestion. :smile: