How does this code work


Ok, so in this code does by_three take the number argument from cube or from itself (if they are different)?

def cube(number):
    return number**3
def by_three(number):
    if number%3==0:
        return cube(number)
        return False


Number is just a local variable for that specific function. Essentially, once the function is done, the variable is gone.


So by the specific function you mean by_three?


Any function. Example:

def stuff(string):
    print string

def things(string):
    array = []

String doesn't mean anything, it just helps you understand what your code does.


Although in stuff, you need to give a value to string so it can be printed.


You must call your function with a value, you don't need to assign string. I could call:


Which would output:



Joel is magic :smiley: :smiley: