Error in modifying each element in a function


multiplying only the first element with 2 not multiplying remaining elements with 2 of the list

Replace this line with your code. 
n = [3, 5, 7]
def double_list(x):
 for i in range(0, len(x)):
    x[i] = x[i] * 2
# Don't forget to return your new list!
    return x
print double_list(n)


Indentation should match the for. This line is currently inside the loop so the return takes places on the first iteration.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.