Review: Built-In Functions - What is the problem?


#1

Review: Built-In Functions

This is my code:

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

And this is the error message I receive

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

What am I doing wrong? Thank you.


#2

This should be a return statement so the value is sent back to the caller.


#3

Hi mtf.

Thanks for your suggestion.Even tohugh I tried several ways based on that
but it didn't worked.

Could you please write the exact line or code?

Regards,

Julio G.


#4

I tried again, and now it's working.

Thanks!


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.