19. Review: Built-In Functions


#1

This is my code

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

This is the error

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

Help please someone give me the answer I have been stuck on this for a week!


#2

Why do you think that your function is returning 25 when you give it -10? How could that happen?


#3

You defined all numbers as 25, but the program wants you to learn how to do generic functions

import math

def distance_from_zero(n):
if type(n)== int or type(n)== float:
return abs(n)

else:
    return "Nope"