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
🌐
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).
Discussions

Skip for loop steps in Python like in C++
if i == 3: continue More on reddit.com
🌐 r/learnprogramming
15
0
April 18, 2023
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
Why isn't my loop iterating backwards in python?
Hint: Look up documentation on the ‘range’ function…does it actually do what you think it does given the two arguments you provided? Maybe you’re missing an argument? https://docs.python.org/3/library/stdtypes.html#range More on reddit.com
🌐 r/learnprogramming
13
0
March 8, 2023
Understanding the For Loop
range() generates numbers. If you only pass 1 argument range(5) it will start from 0 and keep going up, and stop before hitting 5. I know sounds strange but that's how it works. So range(5) gives you 0 1 2 3 4 If you pass 2 arguments, range(1,5), same as above except this time it starts from your first argument, 1. So you get 1 2 3 4 The 3rd argument is how each steps increases. By default it's 1. Let's pass a 2 and see what happens? range(1, 10, 2) --> 1 3 5 7 9. Starts from 1, goes up 2 each time, stops before 10. More on reddit.com
🌐 r/learnpython
62
366
October 9, 2020
🌐
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   4 weeks ago
🌐
Coursera
coursera.org › tutorials › for-loop-python
How to Use For Loops in Python: Step by Step | Coursera
Prerequisites/helpful expertise: Basic knowledge of Python and programming concepts · For loops are control flow tools. They are used to iterate over objects or sequences—like lists, strings, and tuples.
🌐
Python
wiki.python.org › moin › ForLoop
ForLoop - Python Wiki
In Python, this is controlled instead by generating the appropriate sequence. Basically, any object with an iterable method can be used in a for loop. Even strings, despite not having an iterable method - but we'll not get on to that here. Having an iterable method basically means that the data can be presented in list form, where there are multiple values in an orderly fashion.
🌐
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.
Find elsewhere
🌐
Snakify
snakify.org › for loop with range
For loop with range - Learn Python 3 - Snakify
result = 0 n = 5 for i in range(1, n + 1): result += i # this ^^ is the shorthand for # result = result + i print(result) Pay attention that maximum value in range() is n + 1 to make i equal to n on the last step.
🌐
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 ...
🌐
Serverspace
serverspace.io › support › help › for-loop-python
Python 3 For Loop Explained: Syntax and Practical Examples
June 1, 2025 - ... When we determined the start and stop point, we got a result in the range from 10 to 15, excluding the number 15. The step parameter is used to specify the step between the start and stop values.
🌐
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.
🌐
Renan Moura
renanmf.com › início › python for loop increment by 2
Python for loop increment by 2 - Renan Moura
April 16, 2023 - The solution to increment a for loop by 2 in Python is to use the range() function. This function allows you to specify three parameters: start, stop, and step.
🌐
Reddit
reddit.com › r/learnprogramming › skip for loop steps in python like in c++
r/learnprogramming on Reddit: Skip for loop steps in Python like in C++
April 18, 2023 -

Hi all,

I am trying to skip values with an if statement in a for loop in Python and I cannot seem to do it.

What I am trying to do in Python is the following in C++:

[in]:

#include <iostream>

using namespace std;

int main()

{

for (int i = 0;i < 10;i++)

{if (i == 3) i++;

cout<<i;}

}

[out]: 012456789.

When I do this in Python, the for loop does not "skip" value 3, it just prints 4 twice instead of 3 and 4.

I can take this to an extreme and say if i=3: i == 20 and weirdly Python distinguishes between the i inside the for loop and the i with the given value 20 which baffles me.

[in]:

for i in range(10):if i == 3:              i = i+1        print(i)

[out] :0 1 2 4 4 5 6 7 8 9

Is there any solution for this?

Thank you in advance for the help!

🌐
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.
🌐
Programink
programink.com › python-tutorial › for-loop-in-python.html
For Loop In Python
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 ...
🌐
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. By default using the range() function in a for loop, the loop will be incremented by ‘1’ for every iteration.
🌐
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
🌐
Tutorjoes
tutorjoes.in › python_programming_tutorial › for_loop_in_python
For Loop in Python
# For Loop in Python for i in range(0, 21, 2): print(i) for i in range(5): a=int(input("Enter a No : ")) b=int(input("Enter a No : ")) print(a+b) To download raw file Click Here
🌐
Real Python
realpython.com › python-for-loop
Python for Loops: The Pythonic Way – Real Python
February 23, 2026 - Learn how to use Python for loops to iterate over lists, tuples, strings, and dictionaries with Pythonic looping techniques.