You can use a range with a step size of 2:

Python 2

for i in xrange(0,10,2):
  print(i)

Python 3

for i in range(0,10,2):
  print(i)

Note: Use xrange in Python 2 instead of range because it is more efficient as it generates an iterable object, and not the whole list.

Answer from Brian R. Bondy on Stack Overflow
Discussions

For loop with custom steps in python - Stack Overflow
I can make simple for loops in python like: for i in range(10): However, I couldn't figure out how to make more complex ones, which are really easy in c++. How would you implement a for loop like... More on stackoverflow.com
🌐 stackoverflow.com
What will a for loop iterate through? Beginner Question
Hi, I'm practicing for loops and I notice that they change depending on what object you use them on Another way to think about this is to consider that the loop isn't changing, it's doing the same thing every time: stepping over each element in your collection and making it available to the loop body, whatever that element might be. But the question in your title is much more interesting: What will a for loop iterate through? This is a great question, and exactly the correct one - what can you provide as the object on which a for loop will act? Well, remember what the loop does - it steps through the elements that comprise some kind of collection and yields each one, sequentially, to the body of the loop. Thus it follows that any object that constitutes a collection of elements that can be stepped over will work, and we call such a collection iterable. A collection is iterable if, when you call iter on that object, it returns an iterator over its elements. An iterator is an object on which you can call .next() to get the next element, and that raises StopException when you call .next() and it has no further elements to yield. is there a way to work out what the loop will do to an object or file? Generally it shouldn't come as a surprise that a certain object will be iterable, or what elements it will yield when you iterate over it - strings are collections of characters, and files are collections of lines, so it makes some sense that when you iterate over these objects they yield these elements. If you ask yourself "what is this object a collection of?" then generally you can determine for yourself what will happen when you try to iterate over the object. And many objects aren't iterable at all - it doesn't make sense to iterate over an integer, for instance, since that's just a single value. More on reddit.com
🌐 r/learnpython
11
14
May 18, 2019
How can you skip ahead in a for loop?
I think you are describing the continue keyword. More on reddit.com
🌐 r/learnpython
16
2
July 21, 2017
Split List Every Nth Object

Standard grouper for a list is like this:

splits = [old_list[i:i+3] for i in range(0,len(old_list),3)]

For something that works with generators too you can use the "grouper" recipe from itertools docs.

More on reddit.com
🌐 r/learnpython
12
1
May 27, 2019
🌐
W3Schools
w3schools.com › python › python_for_loops.asp
Python For Loops
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-for-loops
Python For Loops - GeeksforGeeks
Python continue Statement returns the control to the beginning of the loop. ... # Prints all letters except 'e' and 's' for i in 'geeksforgeeks': if i == 'e' or i == 's': continue print(i)
Published   2 weeks ago
🌐
Coursera
coursera.org › tutorials › for-loop-python
How to Use For Loops in Python: Step by Step | Coursera
... Write the iterator variable (or loop variable). The iterator takes on each value in an iterable (for example a list, tuple, or range) in a for loop one at a time during each iteration of the loop.
🌐
TutorialKart
tutorialkart.com › python › python-for-loop › python-for-loop-increment-step
Python For Loop Increment in Steps
July 22, 2021 - ... step = int(input('Enter step value : ')) list_1 = [9, 5, 7, 2, 5, 3, 8, 14, 6, 11] for i in range(0, len(list_1), step) : print(list_1[i]) ... In this Python Tutorial, we learned how to use for loop with range() function, to loop through ...
🌐
Programink
programink.com › python-tutorial › for-loop-in-python.html
For Loop In Python
October 9, 2020 - A for loop in python is used to iterable over sequences or collections. It can be programmed to go primarily over index or value. It uses an iterating variable that iterates over the next value from the iterable collection or range() function. range() function makes an iterable object with the given start point, endpoint, and step of traversal.
Find elsewhere
🌐
Python
wiki.python.org › moin › ForLoop
ForLoop - Python Wiki
For loop from 0 to 2, therefore running 3 times. for x in range(0, 3): print("We're on time %d" % (x))
🌐
Serverspace
serverspace.io › support › help › for-loop-python
Python 3 For Loop Explained: Syntax and Practical Examples
June 1, 2025 - One of the built-in sequences is ... sequence (optional parameter and default value 0) ... Step – is a sequence step (optional parameter and default value 1)....
🌐
Snakify
snakify.org › for loop with range
For loop with range - Learn Python 3 - Snakify
Pay attention that maximum value in range() is n + 1 to make i equal to n on the last step. 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 ...
🌐
Renan Moura
renanmf.com › início › python for loop increment by 2
Python for loop increment by 2 - Renan Moura
March 17, 2022 - In this case I’m starting on index 1, which is the number 2 in the list, remember lists are 0-indexed in Python. I won’t put any stop value since I want to go until the last index. Finally, I put a step of 2. numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] for i in numbers[1::2]: print(i)
🌐
Tutorjoes
tutorjoes.in › python_programming_tutorial › for_loop_in_python
For Loop in Python
March 30, 2021 - This program is a Python script that demonstrates the use of the for loop and the built-in ... range() function to create an iterator that generates a sequence of numbers from 0 (inclusive) to 21 (exclusive) with a step of 2.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › how to increment for loop in python
How to Increment For Loop in Python - Spark By {Examples}
May 31, 2024 - step(optional) – The increment between each number in the sequence. If not specified, it defaults to 1. Specifies how to increment the value. ... Python range() function is used to generate a sequence of numbers within a given range.
🌐
OpenStax
openstax.org › books › introduction-python-programming › pages › 5-2-for-loop
5.2 For loop - Introduction to Python Programming | OpenStax
March 13, 2024 - The range() function is a common approach for implementing counting in a for loop. A range() function generates a sequence of integers between the two numbers given a step size. This integer sequence is inclusive of the start and exclusive of the end of the sequence.
🌐
CodeRivers
coderivers.org › blog › how-to-change-step-in-for-loop-python
Mastering the Step Parameter in Python's For Loops - CodeRivers
April 10, 2025 - Fundamental Concepts of Changing Step in a For Loop ... The range() function in Python is often used in for loops to generate a sequence of numbers. The basic syntax of the range() function is range(start, stop, step). - start (optional): The starting value of the sequence.
🌐
University of Pittsburgh
sites.pitt.edu › ~naraehan › python3 › mbb14.html
Python 3 Notes: for Loops
January 31, 2024 - Python 3 Notes [ HOME | LING 1330/2330 ] Tutorial 14: for Loops << Previous Tutorial Next Tutorial >> On this page: using a for loop. Video Tutorial Python 3 Changes print(x,y) instead of print x, y Python 2 vs. 3 Summary · Video Summary Loops are a way to repeat a set of actions a specific ...
🌐
Dataquest
dataquest.io › blog › python-for-loop-tutorial
Python for Loop: A Beginner's Tutorial – Dataquest
March 10, 2025 - Learn to write Python for loops with statements like break and continue to iterate through lists to clean and analyze large datasets quickly.
🌐
Berkeley
pythonnumericalmethods.studentorg.berkeley.edu › notebooks › chapter05.01-For-Loops.html
For-Loops — Python Numerical Methods
The Python function sum has already been written to handle the previous example. However, assume you wish to add only the even numbers. What would you change to the previous for-loop block to handle this restriction? s = 0 for i in range(0, len(a), 2): s += a[i] print(s) ... NOTE! We use step as 2 in the range function to get the even indexes for list a.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-for-loop-example
Python for loop | DigitalOcean
March 14, 2024 - When you want the for loop to run for a specific number of times, or you need to specify a range of objects to print out, the range function works really well. When working with range(), you can pass between 1 and 3 integer arguments to it: start states the integer value at which the sequence begins, if this is not included then start begins at 0 · stop is always required and is the integer that is counted up to but not included · step sets how much to increase (or decrease in the case of negative numbers) the next iteration, if this is omitted then step defaults to 1