Will It Vibe logoWill It Vibe?
PY-016Low severity-4 points

range(len(x)) instead of enumerate()

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

for i in range(len(seq)): followed by indexing works but is less readable and more error-prone than iterating directly with enumerate().

Why it matters

for i in range(len(people)): followed by indexing (people[i]) works but is less readable and slightly more error-prone than iterating directly, since it is easy to accidentally index a different sequence than the one range(len(...)) was computed from once the loop body grows. enumerate() gives you both the index and the item directly and is the idiom Python style guides and most linters (pylint C0200) recommend.

How to fix it

Replace for i in range(len(seq)): ... seq[i] ... with for i, item in enumerate(seq): ... item .... If the index is not actually used inside the loop body, drop it entirely and iterate directly with for item in seq:.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks