I found this previously answered here, Best way to loop over a python string backwards
I need to use OP’s original idea, but I don’t quite understand the meaning of the stop argument in the range function. What does 0-1 mean? From 0-1? Wouldn’t that be the step?
Why can’t you use reversed as accepted in the previously answered question?
However, to answer your original question:
The 0-1 is actually just a number 0-1, which is equal to -1
The documentation for range says the following:
range(start[, end[, step]]). His call looks like the following:range(len(string)-1, 0-1, -1)start =
len(string)-1, which is last letter of the string.end =
0-1which is equal to-1, so the last letter being handled is0. Remember thatrange(0, 3)will actually give0, 1, 2and stop right before the3. Same goes for negative numbers, it will stop right before-1, so it will stop at0.step =
-1. Step stands for how many numbers to step over at once.-1means it will loweriby one every time.