Review Build-in functions -- Stuck, help please


#1



I got the following error messages:
"Oops, try again. It looks like you have a NameError. Maybe you forgot to create a function called distance_from_zero? Check the error message for more info! - global name 'distance_from_zero' is not defined"

And also the error message in the top right window:
File "python", line 1
def distance_from_zero(n)
^
SyntaxError: invalid syntax


I don't understand what's wrong with my code. I went through many topics and none of them can solve my problem. I have been stuck here for a couple of days and can't go through, very frustrated. Can someone help?


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


#2

You missed a colon after name of function!


#3

Thank you so much for your quick reply and fast fixing!! :slight_smile: BIG THANKS!! It works!!! :smile:


#5

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