The range function takes 3 arguments: start, stop, and step:

for i in range(-1, 9):
  yield i

To go in reverse

for i in range(10, 0, -1):
  yield i

Take a look at the documentation.

Edit:

Of course, there's nothing to stop you from using the range directly. Thus map(print, range(10, 0, -1)) will print them all to the screen, while range(10, 0, -1) will give you access to the integers directly.

Answer from wheaties on Stack Overflow
🌐
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 this example, we will use the while loop and i= operation to decrement the value one by one or according to your requirement. We will set the while condition and then decrement the value inside the while function afterward.
Discussions

python - Decrementing for loops - Stack Overflow
I want to have a for loop like so: for counter in range(10,0): print counter, and the output should be 10 9 8 7 6 5 4 3 2 1 More on stackoverflow.com
🌐 stackoverflow.com
Iterate over a list and subtract 1 subsequently and pop in python - Stack Overflow
I want to iterate over a list first pop the last element and then subtract 1 from all values and then repeat. i want to save the popped element in a new list. input- [5 9 5 7] output- [7 4 7 2] More on stackoverflow.com
🌐 stackoverflow.com
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
February 22, 2015
Negative index in python for loop - Stack Overflow
[0, 1, 2, 3] # original [0, 1, ... [3, 1, 2, 3] # prints 3 ^--------| ... One quality every engineering manager should have? Empathy. ... Join us for our first community-wide AMA (Ask Me Anything) with Stack... bigbird and Frog have joined us as Community Managers ... Is it better to redirect users who attempt to perform actions they can't yet... 22 for loops and iterating ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
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. Let's try! >>> for i in range(9, -1, -1): ...
🌐
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.
🌐
Java2Blog
java2blog.com › home › python › how to decrement for loop in python
Python for loop decrement - Java2Blog
October 28, 2021 - To decrement a value in the for loop, the start value should be greater than the stop value, and the step parameter should be a negative integer. ... We define the value for the start, stop, and step parameters.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › decrement-in-while-loop-in-python
Decrement in While Loop in Python - GeeksforGeeks
February 13, 2023 - Firstly a variable is initialized ... aforementioned variable is greater than 0. Then inside the loop body, the variable's value is displayed, and the variable's value is decremented by 1. Hence upon each iteration, the value of variable ...
🌐
CodeSpeedy
codespeedy.com › home › python for loop decrementing index
Python for loop decrementing index - CodeSpeedy
July 21, 2019 - In for loop, index is by default incremented by 1. To decrement the index in for loop, make the step value negative. Hope you got an idea on the topic “Decrementing index in for loop in Python”
🌐
Thecodeforge
thecodeforge.io › home › python › python for loop explained — syntax, examples and common mistakes
Python for Loop Explained — Syntax, Examples and Common Mistakes | TheCodeForge
March 5, 2026 - === Countdown prep === Step 0 Step 1 Step 2 Step 3 Step 4 === Lap counter === Lap 1 complete Lap 2 complete Lap 3 complete Lap 4 complete Lap 5 complete === Even floors only === elevator stops at floor 0 Elevator stops at floor 2 Elevator stops at floor 4 Elevator stops at floor 6 Elevator stops at floor 8 Elevator stops at floor 10 === Rocket launch === T-minus 5... T-minus 4... T-minus 3... T-minus 2... T-minus 1... Liftoff! ... This is the single most common beginner mistake. range(5) gives you [0, 1, 2, 3, 4] — five values, but none of them is 5. If you need to print 1 through 5, use range(1, 6). A good mental model: the stop value is a wall the counter hits but never crosses. A string in Python is just a sequence of characters, and you can loop over it the same way you loop over a list.
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
🌐
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
🌐
GeeksforGeeks
geeksforgeeks.org › python › loops-in-python
Loops in Python - GeeksforGeeks
Python · li = ["geeks", "for", "geeks"] for index in range(len(li)): print(li[index]) Output · geeks for geeks · Explanation: This code iterates through each element of the list using its index and prints each element one by one. The range(len(list)) generates indices from 0 to the length of the list minus 1. while loop is used to execute a block of statements repeatedly until a given condition is satisfied.
Published   3 weeks ago
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-decrement-a-python-for-loop
How to Decrement a Python for Loop - GeeksforGeeks
July 23, 2025 - In this example, the reversed() function is used with range(5) to create an iterator that yields values from 4 to 0. The for loop then iterates over these values, printing each one in reverse order.
🌐
Sololearn
sololearn.com › en › Discuss › 2433661 › why-would-a-for-loop-use-subtraction-instead-of-an-absolute-number
Why would a for loop use subtraction instead of an absolute number? | Sololearn: Learn to code for FREE!
If you come across a code with a for loop that does something similar to the code below, why do you think a subtraction is used instead of an absolute number? for (int i = 0; i < 3 - 1; i++) { //some code } ... To make people understand it more. ...
🌐
Delft Stack
delftstack.com › home › howto › python › decrement a loop python
How to Decrement a Loop in Python | Delft Stack
March 11, 2025 - count = 10 while count > 0: if count % 2 == 0: print(f"{count} is even") else: print(f"{count} is odd") count -= 1 ... In this code, we check if the current count is even or odd. Depending on the condition, we print a corresponding message.
🌐
Python.org
discuss.python.org › python help
Subtracting from a deffined variable that has an intager value in a loop - Python Help - Discussions on Python.org
January 19, 2023 - Hello, I am currently working on a programming assignment for a class I’ve gotten most of the program finished. the problem I’m having is I can’t figure out how to get the program to subtract from the set number of seats and save that as the remaining number of seats in that section of the theater. thus when the program loops back around that is the number of seats that are still available. this is my program so far: def main(): Hall = 300 Mezz = 100 AHT = 10 CHT = 7 AMT = 8 CMT = 5 wh...
🌐
Reddit
reddit.com › r/learnpython › using while loop to subtract
r/learnpython on Reddit: using while loop to subtract
February 11, 2021 -

Would anyone be able to give me a hint for how to solve this? Im having trouble having my digit_2 go down by 1 every time the subtraction happens in my last part of the code. Here is my code

while True:
    try:
        digit = int(input("Part 1: Enter a digit greater than 9 & less than 20: "))
        if digit >= 9 and digit <= 20:
            break
        else:
            print("try again")
    except ValueError:
        print("Provide a number")
        continue
    
while True:
    try:
        digit_2 = int(input("Part 2: Enter a digit greater than Part 1: "))
        if digit_2 > digit:
            break
        else:
            print("Digit 2 is not greater than first digit. Please try again")
    except ValueError:
        print("Provide a number")
        continue
    

x = digit_2   
for x in range(x, 0, - digit):
            print(x)