Task:
- Define a function,
distance_from_zero
with one parameter. - Have that function do the following:
- Check the type of the input it receives.
- If the type is
int
orfloat
, the function should return the absolute value of the function input. - If the type is any other type, the function should return
"Not an integer or float!"
My answer that does not work:
def distance_from_zero(d):
if type(d) == int or float:
return abs(d)
else:
return "Not an integer or float!"