def gen_range(start, stop, step):
    current = start
while current < stop:
    next_current = current + step
if next_current < stop:
    yield current, next_current
else:
    yield current, stop
current = next_current
Generate list of range tuples with given boundaries in python