13/18


#1

def double_list(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x

why we have to return the new list? why it is giving the error when there is no return statement
def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] * 2


#2

because then your double_list only exist inside the function, you can see this nicely if you do this:

def double_list(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x
temp = double_list([1,2,3])
print temp

now remove the return, see what happens


#3

For those of you who didn't notice, makes a big difference the x parameter inside of len().
if you don't change that, you will not have the correct solution.


#4

In essence, what functions do is they take an input and return a value. If there is no return statement, then it returns none. This would be fine, however because we want to see the fruits of our labor, using print like this:
print function_name(argument)
will print whatever the function returns.


#5

Thanks for that! You get a free cookie

:cookie: