Why does this return None (19)


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


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


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)



This code worked

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