While outside of a function, in isolation I can use:
for items in <list_name> to run through every item in the list, in the example below i need to replace list name with range(0, len(list_name)) else it throws the following error:
Traceback (most recent call last):
File “python”, line 9, in
File “python”, line 5, in double_list
IndexError: list index out of range
Any help on this?
n = [3, 5, 7] def double_list(x): for i in x: x[i] = x[i] * 2 return x # Don't forget to return your new list! print double_list(n)