Topic 19


The bubble says Oops, try again. It looks like you have a TypeError. Make sure your function should only take one input. (Or check the error message for more info.) - distance_from_zero() takes no arguments (1 given)
The output box says File "python", line 1
def distance_from_zero(2):
SyntaxError: invalid syntax

Can anyone please help?

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


Your function has 2 (not a valid variable) in the parameter spot that should take an argument.
The structure goes like:

def function(argument1, argument2):
    return argument1 + argument2

The function takes information from outside the function (when it's called) and assigns that information to the argument to be used as a dynamic variable inside the function which allows you to manipulate data without messing with the original data.


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