Well, I initially interpreted the code and question wrong.
We already know but OP seems to have missed the fact that adding characters to a string is going to increase the length the string which in this particular case seem to have lead to the wrongful conclusion that the for loop isn't using a fixed endpoint (to-value).
The original code produces something like:
I \always\ arrive late at the office, but I make up for it by leaving \early\.
len(rezultat) = 78
iterations = 78
I \\always\\ arrive late at the office, but I make up for it by leaving \\early\.
len(rezultat) = 81
... and which seem to have confused OP in believing that the for loop is increasing its to-value check during the loop (which is the wrong conclusion, see the number of iterations which is exactly matching the original length of the string)
But, the string did increase in length from 78 to 81 characters and this is because there was a total of 3 back-slashes added to the string. 81 - 78 = 3 (or 78 + 3 = 81, same numbers)
OP seems to be looking (I have to guess a little) for a solution that does:
I \always\ arrive late at the office, but I make up for it by leaving \early\.
len(rezultat) = 78
iterations = 78
I \\always\\ arrive late at the office, but I make up for it by leaving \\earl
len(rezultat) = 78
Which deletes as many characters from the string (from the end) as there are inserted. Number of iterations stays 78 but also the length of the resulting string stays the same.
Beats me why someone would be looking for such functionality, but I often do no have the foggiest about such things
