diff options
author | 2024-04-16 12:51:38 -0400 | |
---|---|---|
committer | 2024-04-16 12:51:38 -0400 | |
commit | 585f98e135c54aa9a10110abc885a3be221f40ea (patch) | |
tree | 32ccb64d086864a29bc9dd797bf0075957fd5598 | |
parent | fix: bold for list comp name, clean up some language (diff) |
fix: correct language for how the iterator does its thing
Co-authored-by: wookie184 <[email protected]>
-rw-r--r-- | bot/resources/tags/loop-remove.md | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/bot/resources/tags/loop-remove.md b/bot/resources/tags/loop-remove.md index 6acc843fd..2bb81a2e7 100644 --- a/bot/resources/tags/loop-remove.md +++ b/bot/resources/tags/loop-remove.md @@ -9,7 +9,7 @@ for item in data: data.remove(item) print(data) # [2, 4] <-- every OTHER item was removed! ``` -`for` loops track the index of the current item with a kind of pointer. Removing an element causes all other elements to shift, but the pointer is not changed: +While iterating with a for loop, an index tracks the current position in the list. If the list is modified, this index may no longer refer to the same element, causing elements to be repeated or skipped. ```py [1, 2, 3, 4] # First iteration: point to the first element ^ |