Why does this return None (19)


#1

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


#2

Print it to console. You haven't got anything that shows the user the answer. :slight_smile:


#3

I have the same problem, what ever is the code it returns the same error..

here is the code I am using - [ i have used, input and print to check the code]

import math
a=input ("enter number:")
def distance_from_zero(a):
if type(a)==int:
print abs(a)
elif type(a)==float:
print abs(a)

distance_from_zero(a)


#4

This code worked

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