r/pythonhelp • • Dec 02 '25

[ Removed by moderator ]

[removed] — view removed post

1 Upvotes

2 comments sorted by

View all comments

1

u/[deleted] Dec 02 '25

When all three values are positive, the algorithm is equivalent to this:

def slice(list, start, stop, step):
    ret = []
    i = start
    while i < stop:
        ret.append(list[i])
        i += step
    return ret

There are other edge cases where the values are 0, negative, or left empty, but this is the basic idea.