Can somebody help me understand why I'm getting this result?
I'm trying to reverse this list using indexing.
def reverse_list(nums):
for i in range(len(nums)):
nums[i] = nums[-i-1] # I think the problem is here in the assigning part
numbers = [1, 2, 3, 4]
reverse_list(numbers)
Output:
[4, 3, 3, 4]
Desired output:
[4, 3, 2, 1]