a = " ".join(str(i) for i in range(10, 0, -1))
print (a)
Answer from user225312 on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-decrement-a-python-for-loop
How to Decrement a Python for Loop - GeeksforGeeks
July 23, 2025 - ... The loop prints each value in descending order. In this example, the range(4, -1, -1) function generates a sequence starting from 4 and decrementing by 1 until reaching -1 (exclusive).
Discussions

Python for loop decrementing index - Stack Overflow
So I wrote a for loop like this: for i in range(size): if(.....) .... i-=1 else: .... I try to decrease the index by 1 if it is inside the if statement, but apparently I can't do t... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Is there a way to change the value of range in a for loop?
It's hard to give feedback if you don't tell us what you want to do. More on reddit.com
๐ŸŒ r/learnpython
26
10
June 20, 2023
python - how to decrement the loop - Stack Overflow
Find centralized, trusted content ... you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I'm wondering if there is any possible way to decrement the loop in python? Iโ€™ve searched on many websites but I didnโ€™t find anything helpful. For example, I ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to decrement using a for or while loop?
I am new to Python programming. The code below works just fine but I want to decrement the initialized amount of tickets which is 100 until it hit zero tickets. For instance, below if you run my code, I enter the input of three; it outputs the difference of the initialized value of 100 and the result is 97 tickets. I want to loop ... More on teamtreehouse.com
๐ŸŒ teamtreehouse.com
7
April 9, 2019
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ perform for loop decrement in python
Perform For Loop Decrement in Python - Spark By {Examples}
May 31, 2024 - How to decrement (for example by 2) for loop in Python? usually, Python for loop is incremented by 1 value however sometimes you would be required to
๐ŸŒ
LearnPython.com
learnpython.com โ€บ blog โ€บ decrement-in-python-for-loop
How to Decrement a Python for Loop | LearnPython.com
August 22, 2022 - The previous example provides some insight on how to decrement in a Python for loop using range(). We can apply it in a straightforward manner by setting the start and the end parameters so that end < start and thereโ€™s a negative step value.
๐ŸŒ
Python Pool
pythonpool.com โ€บ home โ€บ blog โ€บ 4 ways to decrement for loop in python
4 Ways to Decrement for loop in Python - Python Pool
January 3, 2024 - In these examples, we will learn how to decrease the value in the for loop in Python. We will be explaining all the examples in detail. In this example, we will use the start index and stop index, decreasing the value in the for loop.
๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ decreasing for loops in python
Decreasing For Loops in Python - AskPython
March 9, 2023 - Since the range() function can be used in addition with the for loop in python, we can use it to iterate through a data set backwards.
๐ŸŒ
datagy
datagy.io โ€บ home โ€บ python posts โ€บ how to decrement a for loop in python
How to Decrement a For Loop in Python โ€ข datagy
September 20, 2022 - We then loop over our list while the value of our integer is greater than or equal to 0. After each iteration, we decrement the value of our integer by 1, using the augmented assignment operator.
Find elsewhere
๐ŸŒ
Newtum
newtum.com โ€บ material โ€บ python โ€บ for-loop-in-python-with-decrement
For Loop in Python with Decrement | Core Python
The second print statement introduces another decrement example โ€” printing even numbers backward. The second for loop uses range(20, 1, -2), meaning it starts at 20, stops before 1, and decreases by 2 each iteration.
๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ python โ€บ how to decrement for loop in python
Python for loop decrement - Java2Blog
October 28, 2021 - We need to decrement a for loop when we wish to execute something in reverse order. Python does not make use of the decrement operator in the for loop.
Top answer
1 of 5
18

I would like to go over the range() function yet again through the documentation as provided here: Python 3.4.1 Documentation for range(start, stop[, step])

As shown in the documentation above, you may enter three parameters for the range function 'start', 'stop', and 'step', and in the end it will give you an immutable sequence.

The 'start' parameter defines when the counter variable for your case 'i' should begin at. The 'end' parameter is essentially what the size parameter does in your case. And as for what you want, being that you wish to decrease the variable 'i' by 1 every loop, you can have the parameter 'step' be -1 which signifies that on each iteration of the for loop, the variable 'i' will go down by 1.

You can set the 'step' to be -2 or -4 as well, which would make the for loop count 'i' down on every increment 2 down or 4 down respectively.

Example:

for x in range(9, 3, -3):
    print(x)

Prints out: 9, 6. It starts at 9, ends at 3, and steps down by a counter of 3. By the time it reaches 3, it will stop and hence why '3' itself is not printed.

EDIT: Just noticed the fact that it appears you may want to decrease the 'i' value in the for loop...? What I would do for that then is simply have a while loop instead where you would have a variable exposed that you can modify at your whim.

test = 0
size = 50
while (test < size)
    test += 1
    if (some condition):
        test -= 1
2 of 5
6

For such a construct, where you need to vary the loop index, a for loop might not be the best option.

for <var> in <iterable> merely runs the loop body with the <var> taking each value available from the iterable. Changing the <var> will have no effect on the ensuing iterations.

However, since it is usually tricky to work out the sequence of values i will take beforehand, you can use a while loop.

i = 0
while i < size:
    if condition:
        ...
        i -= 1
    else:
        ...
        i += 1
๐ŸŒ
Replit
replit.com โ€บ home โ€บ discover โ€บ how to decrement a for loop in python
How to decrement a for loop in Python | Replit
February 20, 2026 - The language doesn't have a built-in reverse step, so you'll use the range() function with a negative step argument. In this article, you'll explore several techniques to count backward.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ decrement a loop python
How to Decrement a Loop in Python | Delft Stack
March 11, 2025 - Can I decrement by numbers other than 1? Yes, you can specify any step size in the range function for a for loop or adjust the decrement value in a while loop. How do I stop a loop prematurely?
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ learning python โ€บ increment and decrement in python
Increment and Decrement in Python
November 11, 2024 - This is particularly useful when ... Here, the loop prints the value of counter until it reaches 0. With each iteration, counter -= 1 decreases the value by 1. A: Python emphasizes readability and simplicity, and the ++ and -- ...
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 60367496 โ€บ how-to-decrement-the-loop
python - how to decrement the loop - Stack Overflow
If you want to have an array index, for instance, that increments or decrements by variable amounts on each iteration, you just declare them above the for statement, and in the loop increment them as you have it above.
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ how-to-decrement-using-a-for-or-while-loop
How to decrement using a for or while loop? (Example) | Treehouse Community
April 9, 2019 - I am new to Python programming. The code below works just fine but I want to decrement the initialized amount of tickets which is 100 until it hit zero tickets. For instance, below if you run my code, I enter the input of three; it outputs the difference of the initialized value of 100 and the result is 97 tickets. I want to loop ...
๐ŸŒ
Dyclassroom
dyclassroom.com โ€บ python โ€บ python-increment-and-decrement-operators
Python - Increment and Decrement Operators - Python - dyclassroom | Have fun learning :-)
Some of the possible logical reasons for not having increment and decrement operators in Python are listed below. Can achieve similar result using += and -=. Including ++ and -- will result in the addition of some more opcode to the language which may result into slower VM engine. Common use of ++ and -- is in loop and in Python for loop is generally written as for i in range(0, 10) thus removing the need for a ++ operator.
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 1356448 โ€บ in-python-can-we-decrement-the-control-variable-in-for-loop
In python, can we decrement the control variable in for loop? | Sololearn: Learn to code for FREE!
From what I have observed, the for loop in Python doesn't need a separate code to increment the control variable but how do I decrement the control variable in the loop.
๐ŸŒ
Besant Technologies
besanttechnologies.com โ€บ home โ€บ blogs โ€บ general โ€บ python loops
Python Loops | Loops in Python | Python Tutorials For Beginners
October 8, 2021 - For loop in python is used to iterate of any sequence such as list or a string. For loop which is used to executing a block of statements or code several times until the given values are iterate able. ... We need to assign a value with list value to be iterating value rather than conditional value are not assigned. ... We need to set a variable to passed in the statement and which are executed till the iterating values . ... We no need to set a decrement /increment value based the needs of the function or statement the statement of loop is based on the list value.
๐ŸŒ
Real Python
realpython.com โ€บ lessons โ€บ range-decrementing
Decrementing With range() (Video) โ€“ Real Python
01:45 That looks like this. for i in reversed() and Iโ€™ll pass in range(5). print(i). The range() function will give us a list from 0 to 4, and reversing that will allow us to iterate from the last value in the list down to the first. 02:11 You could also accomplish this by just using the range() function without reversed(), but weโ€™ve included this here to show you another way you might see iteration done. Become a Member to join the conversation. ... Get a Python Cheat Sheet (PDF) and learn the basics of Python, like working with data types, dictionaries, lists, and Python functions:
Published ย  October 15, 2019