aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/resources/tags/range-len.md4
1 files changed, 2 insertions, 2 deletions
diff --git a/bot/resources/tags/range-len.md b/bot/resources/tags/range-len.md
index 4bd377d59..76fe9051e 100644
--- a/bot/resources/tags/range-len.md
+++ b/bot/resources/tags/range-len.md
@@ -2,12 +2,12 @@
embed:
title: "Pythonic way of iterating over ordered collections"
---
-Iterating over `range(len(...))` is a common approach to accessing each item in an ordered collection.
+Beginners often iterate over `range(len(...))` because they look like Java or C-style loops, but this is almost always a bad practice in Python.
```py
for i in range(len(my_list)):
do_something(my_list[i])
```
-The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:
+It's much simpler to iterate over the list (or other sequence) directly:
```py
for item in my_list:
do_something(item)