Please solve my issue in python/function/19.Review: Built-In Functions


#1



https://www.codecademy.com/en/courses/python-beginner-c7VZg/4/3?curriculum_id=4f89dab3d788890003000096#


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


save and submit successfully without return any thing because it doesn't return any result for specific value


Replace this line with your code. 

def distance_from_zero(s):
    return type(s) == int or type(s) == float
    
abs(-10)


#2

We have to check if s is int type or float,if it is then return the absolute value of s.

use if-statement ?


#3

i also use this one but same message shown

def distance_from_zero(s):
if type(s) == int or type(s) == float:
return True
else:
return False

abs(-10)


#4

Just one problem, we have to return absolute value of number , right? not a boolean value.. ( return True )


#6

It is working now
thanks sorry it all my mistake in understanding the question


#7

Its happens!:slight_smile: reading instruction and theory of exercise helps a lot ! :slight_smile:


#8

here you go......

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


#9

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