diff options
author | 2024-04-16 13:14:22 -0400 | |
---|---|---|
committer | 2024-04-16 13:14:22 -0400 | |
commit | 9e72c6d4ff698e1c8ff08da50e02c9515a13b1d7 (patch) | |
tree | 814b3c17e1c97ec66f98557bb942580fe6128af7 | |
parent | fix: text-only explanation (diff) |
fix: "in the example", less terse and less confusing
-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 14b6fc89b..f43097a2d 100644 --- a/bot/resources/tags/loop-remove.md +++ b/bot/resources/tags/loop-remove.md @@ -12,7 +12,7 @@ print(data) # [2, 4] <-- every OTHER item was removed! ``` Inside the loop, an index tracks the current position. If the list is modified, this index may no longer refer to the same element, causing elements to be repeated or skipped. -Above, `1` is removed, shifting `2` to index *0*. The loop then moves to index *1*, removing `3` (and skipping `2`!). +In the example above, `1` is removed, shifting `2` to index *0*. The loop then moves to index *1*, removing `3` (and skipping `2`!). You can avoid this pitfall by: - using a **list comprehension** to produce a new list (as a way of filtering items): |