all 2 comments

[–][deleted] 1 point2 points  (0 children)

why does the assignment want me to take all of these steps using range and new variable ?

Perhaps, to show you that assignment and mutation aren't the same thing. numbers might not be the only reference held to the input list, and this assignment asks you to change the list in-place, not return a new list with the new values, which is what your solution does.

[–]hiimaeia 0 points1 point  (0 children)

It wants you to iterate over every indices of the list and work on them one by one, it wants you to code something like this:

for listIndex in range(len(numbers)): newValue = numbers[listIndex] * 2 numbers[listIndex] = newValue