Aug-27-2021, 03:49 PM
What do you mean by "work backward"? The action is a bit confusing because you're modifying a list at the same time as you're reading it for information.
Start with [1, 2, 3].
First time through the loop, you tell it copy element 0 (which is a 1) to spot 1. -> [1, 1, 2, 3]
Next time through the loop, you tell it copy element 1 (which is now a 1) to spot 1 -> [1, 1, 1, 2, 3]
Next time through the loop, you tell it copy element 2 (which is now a 1) to spot 1 -> [1, 1, 1, 1, 2, 3]
It doesn't add 1, 2, 3 because myList has changed by the time the element is looked for.
Start with [1, 2, 3].
First time through the loop, you tell it copy element 0 (which is a 1) to spot 1. -> [1, 1, 2, 3]
Next time through the loop, you tell it copy element 1 (which is now a 1) to spot 1 -> [1, 1, 1, 2, 3]
Next time through the loop, you tell it copy element 2 (which is now a 1) to spot 1 -> [1, 1, 1, 1, 2, 3]
It doesn't add 1, 2, 3 because myList has changed by the time the element is looked for.