for i in range(len(a)-1,-1,-1):
to iterate backwards over the indices of a list. Range should be
defined so that you can simply say:
for i in range(len(a),0,-1):
If k>0, this could be done by defining
to be equivalent to
That is to say, if the third argument is negative then the range
that is produced includes the second argument but not the first.
If the third argument is positive the range includes the first
argument but not the second as is currently the case.
Lou Kates, email@example.com