From the documentation:

range([start], stop[, step])

The start defaults to 0, the step can be whatever you want, except 0 and stop is your upper bound, it is not the number of iterations. So declare n to be whatever your upper bound is correctly and you will not have to add 1 to it.

e.g.

>>> for i in range(1, 7, 1): print(i)
... 
1
2
3
4
5
6
>>> for i in range(1, 7, 2): print(i)
... 
1
3
5

A nice feature, is that it works in reverse as well.

>>> for i in range(7, 0, -1): print(i)
... 
7
6
5
4
3
2
1

If you aren't using it as an index but for something that can have positive or negative values, it still comes in handy:

>>> for i in range(2, -3, -1): print(i)
... 
2
1
0
-1
-2
>>> for i in range(-2, 3, 1): print(i)
... 
-2
-1
0
1
2
Answer from Rolf of Saxony on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_for_loops.asp
Python For Loops
To loop through a set of code a specified number of times, we can use the range() function, The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.
๐ŸŒ
Python
wiki.python.org โ€บ moin โ€บ ForLoop
ForLoop - Python Wiki
x = 1 while True: print("To infinity and beyond! We're getting close, on %d now!" % (x)) x += 1 ยท When running the above example, you can stop the program by pressing ctrl+c at the same time. As you can see, these loop constructs serve different purposes. The for loop runs for a fixed amount of times, while the while loop runs until the loop condition changes.
Discussions

python - Pythonic way to iterate through a range starting at 1 - Stack Overflow
Rather than using +1 once when defining the loop I may have to use it multiple times. 2015-10-22T13:44:44.787Z+00:00 ... Not a general answer, but for very small ranges (say, up to five), I find it much more readable to spell them out in a literal: More on stackoverflow.com
๐ŸŒ stackoverflow.com
Understanding the Role of 'i = i + 1' in a Python For Loop Incrementation - Stack Overflow
I am new to programming and trying to learn for loops. My question is regarding the following code: numbers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40] i = 0 for More on stackoverflow.com
๐ŸŒ stackoverflow.com
Python for loop question - Stack Overflow
Python's for loops are different. i gets reassigned to the next value every time through the loop. The following will do what you want, because it is taking the literal version of what C++ is doing: i = 0 while i < some_value: if cond...: i+=1 ...code... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do you start a for loop at 1 instead of 0?
Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission: You are looping over an object using something like for x in range(len(items)): foo(item[x]) This is simpler and less error prone written as for item in items: foo(item) If you DO need the indexes of the items, use the enumerate function like for idx, item in enumerate(items): foo(idx, item) More on reddit.com
๐ŸŒ r/learnpython
16
6
November 13, 2015
๐ŸŒ
Real Python
realpython.com โ€บ python-for-loop
Python for Loops: The Pythonic Way โ€“ Real Python
February 23, 2026 - Jane 25 Python Dev Canada >>> text = "abcde" >>> for character in text: ... print(character) ... a b c d e >>> for index in range(5): ... print(index) ... 0 1 2 3 4 ยท In these examples, you iterate over a tuple, string, and numeric range. Again, the loop traverses the sequence in the order of definition.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ loops-in-python
Loops in Python - GeeksforGeeks
For loops is used to iterate over a sequence such as a list, tuple, string or range. It allow to execute a block of code repeatedly, once for each item in the sequence. ... Explanation: This code prints the numbers from 0 to 3 (inclusive) using a for loop that iterates over a range from 0 to n-1 (where n = 4)...
Published ย  1 week ago
๐ŸŒ
Learn Python
learnpython.org โ€บ en โ€บ Loops
Loops - Learn Python - Free Interactive Python Tutorial
For loops can iterate over a sequence of numbers using the "range" and "xrange" functions. The difference between range and xrange is that the range function returns a new list with numbers of that specified range, whereas xrange returns an iterator, which is more efficient. (Python 3 uses the range function, which acts like xrange). Note that the range function is zero based. # Prints out the numbers 0,1,2,3,4 for x in range(5): print(x) # Prints out 3,4,5 for x in range(3, 6): print(x) # Prints out 3,5,7 for x in range(3, 8, 2): print(x)
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-for-loops
Python For Loops - GeeksforGeeks
In Python, enumerate() function is used with the for loop to iterate over an iterable while also keeping track of index of each item. ... This code uses nested for loops to iterate over two ranges of numbers (1 to 3 inclusive) and prints the ...
Published ย  4 weeks ago
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-for-loop-for-i-in-range-example
Python For Loop - For i in Range Example
March 30, 2021 - As discussed in Python's documentation, for loops work slightly differently than they do in languages such as JavaScript or C. A for loop sets the iterator variable to each value in a provided list, array, or string and repeats the code in the body of the for loop for each value of the iterator variable. In the example below, we use a for loop to print every number in our array. # Example for loop for i in [1, 2, 3, 4]: print(i, end=", ") # prints: 1, 2, 3, 4,
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ how to start python for loop at 1
How to Start Python For Loop at 1 - Spark By {Examples}
May 31, 2024 - To start the for loop with index at 1 in Python use the range() with start param at 1 and for the end value use the len() which gives the length of the sequence object. With this we can start the for loop at index 1.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-start-a-for-loop-at-1-python
How to start a for loop at 1 - Python - GeeksforGeeks
July 23, 2025 - In scenarios where a loop inherently starts at 0 we can initialize a counter variable at 1 and increment it manually. ... # Initialize counter start = 1 for _ in range(5): # Loop 5 times print("Current number:", start) start += 1
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ for-loop
Python for Loop (With Examples)
Here, we have printed each character of the string language using a for loop. In Python, the range() function returns a sequence of numbers. For example, # generate numbers from 0 to 3 values = range(0, 4) Here, range(0, 4) returns a sequence of 0, 1, 2 , and 3.
๐ŸŒ
Snakify
snakify.org โ€บ for loop with range
For loop with range - Learn Python 3 - Snakify
To iterate over a decreasing sequence, we can use an extended form of range() with three arguments - range(start_value, end_value, step). When omitted, the step is implicitly equal to 1. However, can be any non-zero value. The loop always includes start_value and excludes end_value during iteration:
๐ŸŒ
Python Course
python-course.eu โ€บ for_loop.php
20. For Loops | Python Tutorial | python-course.eu
... # Get the value of n from the user n = int(input("Enter the number of Fibonacci numbers to generate: ")) # Initialize the first two Fibonacci numbers fibonacci_sequence = [0, 1] # Generate and print the Fibonacci sequence using a for loop for i in range(2, n): next_number = fibonacci_s...
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-for-loop-example
Python for loop | DigitalOcean
March 14, 2024 - for n in range(1, 10, 3): print("Printing with step:", n) # Output # Printing with step: 1 # Printing with step: 4 # Printing with step: 7 ยท We can also use a negative value for our step argument to iterate backwards, but weโ€™ll have to adjust our start and stop arguments accordingly: ... Here, 100 is the start value, 0 is the stop value, and -10 is the range, so the loop begins at 100 and ends at 0, decreasing by 10 with each iteration. This occurs in the output: ... When programming in Python, for loops often make use of the range() sequence type as its parameters for iteration.
๐ŸŒ
Syntaxdb
syntaxdb.com โ€บ ref โ€บ python โ€บ for-loop
For Loop in Python - SyntaxDB - Python Syntax Reference
The for loop is used to iterate through a sequence. When a range is provided as the sequence, it behaves like a C-style for loop. For all other sequences (arrays, etc.), it behaves like a for each loop.
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ for-loop
Python For Loop: Syntax and Examples [Python Tutorial]
In this example, the loop iterates over the list of numbers with a starting value of 1. Each iteration assigns the current value from the sequence of numbers to number. The function call in the code block prints each number in the list. range() is a built-in function that creates a list of numbers starting at 0 and stopping before a specified integer. This makes the range function ideal for creating Python ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ what exactly is i in a for loop?
r/learnpython on Reddit: What exactly is i in a for loop?
December 10, 2024 -

I was working on a beginner's python exercise that involved writing a function that takes a list of floating numbers and returns the same list as strings displayed to 2 decimal places. This was what I initially wrote:

def formatted(a_list):
    for i in a_list:
        i = f"{i:.2f}"
    return a_list

print(i) after i = f"{i:.2f}" showed correct values, but the returning a_list remained unedited. It seems to me that i does not represent the actual items within a_list, but behaves more so like a copied value?

I solved the problem by .append()-ing the formatted items to a new list but my lack of genuine understanding bugs me.

What's happening under the hood? What exactly is i in a for loop? Thanks!