I need Help with Review:Built in Functions, I put the code exactly as it said to do but it still doesn't work!


#1



https://www.codecademy.com/courses/python-beginner-c7VZg/4/3

It keeps saying "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", it also says in the box in the top right corner (output) File "python", line 4
SyntaxError: 'return' outside function


I expect the code to work so I can go onto the next lesson.


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


#2

That line is preventing the function from actually running. It just returns the number that was passed in.


#3

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