Skip to content

Instantly share code, notes, and snippets.

@HarkonenBade
HarkonenBade / enum_step.py
Last active February 20, 2016 23:25 — forked from cillian64/enum_step.py
enum_step
def enum_step(seq, start=0, step=1):
"""
Like the builtin enumerate(seq), but with adjustable stepping. Useful for backwards enumeration:
for idx,x in enum_step(reversed(seq), len(seq)-1, -1):
...
"""
for i, x in enumerate(seq):
yield (start + (i*step), x)