Modifying each element in a list in a function


#1

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

Don't forget to return your new list!

print double_list(n)

Here what I did wrong ?


#2

a function ends the moment a return keyword is reached, if a return keyword is reached in a loop, the loop breaks


#3

Thanks it worked........:slight_smile:


#4