names = []
for i in range(len(users)):
names.append(users[i].name)Deterministic line match: flags `for name in range(len(seq)):` where the argument is exactly `len()` of a name or dotted attribute. Reported at info severity.
`for i in range(len(items)):` is a C-style index loop where Python offers direct iteration or `enumerate`.
Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.
names = []
for i in range(len(users)):
names.append(users[i].name)Deterministic line match: flags `for name in range(len(seq)):` where the argument is exactly `len()` of a name or dotted attribute. Reported at info severity.
names = [user.name for user in users]
for position, user in enumerate(users, start=1):
print_row(position, user.name)Iterate directly (`for item in items`), use `enumerate(items)` when you need the index too, and `zip` when walking two sequences together.
Agents carry index-loop habits over from other languages and keep the index plumbing even when the body only reads `items[i]`.
ai-slop/python-range-len-loop
ai-slop
Deterministic line match: flags `for name in range(len(seq)):` where the argument is exactly `len()` of a name or dotted attribute. Reported at info severity.
Direct iteration, `enumerate(...)`, and ranges with offsets or steps such as `range(1, len(x))` or `range(len(x) - 1)` are not flagged.
Shipped in aislop v0.9.4 as one of four Python verbosity rules drawn from SlopCodeBench (arXiv 2603.24755).