Modifying each element in a list in a function

n = [3, 5, 7]

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

Don’t forget to return your new list!

print double_list(n)

1 Like

i see code, what about it? Do you have a question?

1 Like

what’s wrong in it …i am confused

1 Like

what happens when you add a second function call:

print double_list(n)
print double_list([2, 4, 6, 8])

that doesn’t seem to go well.

the function should be written in such a way, that it works for any valid list passed as argument at function call


thanks finally it works :grinning::grinning::grinning::grinning::grinning:

1 Like