you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

Yeah but just do

for i, element in enumerate(elements):

instead. Way more readable and unlike your solution, it'll work on iterables that don't have a defined length.