Built in functions


#1

Oops, try again. It looks like you have a TypeError. Make sure your function should only take one input. (Or check the error message for more info.) - 'int' object is not callable
Code: def distance_from_zero(t):
if type(t) == int or type(t) == float:
return t(abs)
else:
return "Nope"
I tried using FireFox Mozilla, Google Chrome and Internet Explorer.


#2

abs() is the function call and should have t as argument, not the other way around like you did


#3

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

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


#5

why do you have an elif condition?


#6

Just realized I read the instructions wrong. Got it by simply taking the elif out. noob mistake, thanks!


#7

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