aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Galen Rice <[email protected]>2024-04-16 12:51:38 -0400
committerGravatar GitHub <[email protected]>2024-04-16 12:51:38 -0400
commit585f98e135c54aa9a10110abc885a3be221f40ea (patch)
tree32ccb64d086864a29bc9dd797bf0075957fd5598
parentfix: 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.md2
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
^