13. Modifying each element in a list in a function
I believe I got the formula correctly but still find it hard to understand why I need to write for i in range(0,len(x)) instead of for i in x? Is range necessary for the formula to recognise that I am using a list?
n = [3, 5, 7] def double_list(x): for i in range(0, len(x)): x[i] = x[i] * 2 return x print double_list(n)