I have a question about the range function. How is it that the function has three parameters (start, stop, step), but the mandatory one (stop) is in the MIDDLE? I thought mandatory parameters have to be at the beginning, and optional parameters come afterwards? When I try to create my own function with a mandatory parameter after an optional parameter, I get an error "non-default argument follows default argument". I suppose the actual implementation of range could make it only an illusion that the middle parameter is mandatory, and there's actually some work done behind the scenes. But I'm hoping someone knows the answer to this..?

For reference, here is the printing of help(range):

range([start,] stop[, step]) -> list of integers

Return a list containing an arithmetic progression of integers.

range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.

When step is given, it specifies the increment (or decrement).

For example, range(4) returns [0, 1, 2, 3]. The end point is omitted!

These are exactly the valid indices for a list of 4 elements.