def list_function(n):

return n[1] + 3

n = [3, 5, 7]

n[1] = list_function(n)

print list_function

the program shows an error, what did i do wrong? I do not exactly understand how to do this. Please reply ASAP, thanks.

def list_function(n):

return n[1] + 3

n = [3, 5, 7]

n[1] = list_function(n)

print list_function

the program shows an error, what did i do wrong? I do not exactly understand how to do this. Please reply ASAP, thanks.

Oops, i copied the wrong code, i meant:

def double_list(x):

for i in range(0, len(n)):

n[i] = n[i] * 2

return n

n = [3, 5, 7]

print double_list(n)

protip: If you want quick replies then explain what's wrong and format your code and don't say "asap". Make it appealing instead of telling others that you're top priority.

n = [3, 5, 7]

for i in range(0, len(n)):

n[i] = n[i] * 2

def double_list (x):

for i in range(0, len(x)):

x[i] = x[i] * 2

return x

print double_list(n)

I don't know if you are still struggling with this: take the return x out of the for loop (i.e. get rid of one of the indentations).

I'm confused that it's just '`return x`

' and not return ``double_list(x)``

- actually my first attempt was `return double_list(n)`

.

Can you explain why it is just `return x`

and not either of the other two?

if you will retutn double_list(n) or double_list(X) it will call double _list function repeteadly. Hence,it will go into infinite loop. Thus, we have to usereturn X only.

Below, is an answer.

x = [3, 5, 7]

def double_list(x):

for i in range(0, len(x)):

x[i] = x[i] * 2

return x

print double_list(x)