Can't multiply any list by 2


Hello evryone :slight_smile:

My code is behaving incorrectly as it does not return any list multiplied by two but instead returns n. anyone know why ?

I happen to return all the items of any inputed list by 2

my code: 

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

Thanks in advance,


Your double_list(x) should iterate through a list passed as argument to this function.
Change your for to iterate over all list, not only over first and second element.

def double_list(x):
    for index in range(len(x)): # len(x) returns length of list
        x[index] *= 2 # x[index] *= 2 is same as x[index] = x[index] * 2
    return x # return should be after loop, not inside


Thank you for your answer. I really apologise for not checking code academy sooner.