Could someone help please


#1

n = [3, 5, 7]

for i in range(0, len(n)):
n[i] = n[i] * 2

Don't forget to return your new list!

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


#2

Hi try to remove the first for in range..


#3

didn't make any difference


#4

Well remove the first for range... and keep only the n array and in this operation n[i] = x[i] * 2 you need to change the n by x like that x[i] = x[i] * 2


#5

n = [3, 5, 7]

for i in range(0, len(n)):
    x[i] = x[i] * 2
# Don't forget to return your new list!
def double_list(x):
    return x[i]
print double_list(n)

raceback (most recent call last):
File "python", line 4, in
NameError: name 'x' is not defined


#6

In your original post you had:

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

On "this line" above, you are doubling the element x[i] correctly, but why are you putting it in n list? You have to put it into x list.

And, remove the:

for i in range(0, len(n)):
    n[i] = n[i] * 2

if the above does not help.