a=raw_input(“Enter a number”)
def distance_from_zero(a):

if type(a)==int or type(a)==float:
print (abs(a))
print “Nope”


Why is this program always giving output as nope inspite of entering an integer as an input?

So type a isn’t a integer or a float, what is it then? might be a good thing to check

i will give you a hint:

specifically this bit: The function then reads a line from input, converts it to a string (stripping a trailing newline),

1 Like