19/19- Need help!


This is my code:

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

I don't know what to do!!!!


Hi @j4m3sh,

You do not need that 'elif' statement just your if and your else because you've modified your first condition to accept both float or integers >"if type(num) == int or type(num) == float:".< After, you will now be able to call your 'distance_from_zero(num)' function without error.

Happy Coding,



Hi @j4m3sh, your code is working without errors. Are you getting any error like "Oops! Try again"? If so, please post it, along with the exercise link. Thanks!

And, as @leocrimson mentioned, your elif branch is redundant, but would not cause any error as such.

P.S. I formatted your code in your post. Have a look at the tutorial :wink: