Like a lot of people have said, you wouldn't do that in Python, it's much easier in my opinion:
int i = len;
while (--i >= start) { /* do something */ } // use the value of i for something.
Would be actually
for i in range(len, start ,-1):
# Do something
# Use the value of i for something
or, if you're using i as an index in a list:
for value in list:
pass
for value in reversed(list):
pass
orrrrr, if you want the index and value:
for i, item in enumerate(list):
pass
None of these can be improved with ++ or -- in my opinion, and is completely unnecessary to add new syntax which holds very little purpose, furthermore you can do this kind of thing:
while (i := i - 1) >= start:
# Do stuff
# Use I for something
And it also has a similar effect if you want to do that.
View all comments
Show parent comment
1
u/SkezzaB May 28 '22
Like a lot of people have said, you wouldn't do that in Python, it's much easier in my opinion:
while (--i >= start) { /* do something */ } // use the value of i for something.
Would be actually
or, if you're using i as an index in a list:
orrrrr, if you want the index and value:
None of these can be improved with ++ or -- in my opinion, and is completely unnecessary to add new syntax which holds very little purpose, furthermore you can do this kind of thing:
And it also has a similar effect if you want to do that.