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
🌐
Renan Moura
renanmf.com › início › python for loop increment by 2
Python for loop increment by 2 - Renan Moura
November 4, 2020 - 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.
🌐
Delft Stack
delftstack.com › home › howto › python › python for loop increment by 2
How to Increment by 2 in Python for Loop | Delft Stack
February 2, 2024 - To increment by 2 in a Python for loop, you can set the step parameter of the range() function to 2.
🌐
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 an ...
🌐
Java2Blog
java2blog.com › home › python › for loop increment by 2 in python
For Loop Increment By 2 in Python - Java2Blog
March 7, 2022 - As we have specified the step parameter as 2, the for loop increments by 2 because the range() function returns a sequence having a difference of 2 between the consecutive elements.
🌐
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 - Python for loop is usually increment by 1 value however sometimes you would be required to increment 2, 3, 4 e.t.c. You can easily achieve this by using the range() function, with the range you can increment the for loop index with a positive ...
🌐
PYnative
pynative.com › home › python › python range() explained with examples
Python range() Function Explained with Examples
March 13, 2024 - You can also define it as a difference between each preceding and next number in the result sequence. For example, If the step is 2, then the difference between each preceding and following number is 2
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-for-loops
Python For Loops - GeeksforGeeks
range(start, stop, step): Generates numbers from start to stop-1, incrementing by step. Python · for i in range(0, 10, 2): print(i) Output · 0 2 4 6 8 · Loop control statements change execution from their normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.
Published   2 weeks ago
🌐
Real Python
realpython.com › lessons › stepping-through-code
Stepping Through Code (Video) – Real Python
There are two commands we can use to step through code when debugging: n, short for next, and s, short for step. If you’ve ever used a debugger before, you’re probably familiar with these already. n is equivalent to step over, and s is ...
Published   September 17, 2019
🌐
In Easy Steps
ineasysteps.com › home › shop › python in easy steps, 2nd edition
Python in easy steps, 2nd edition - In Easy Steps
February 19, 2025 - Python in easy steps, 2nd edition begins by explaining how to install the free Python interpreter so you can quickly begin to create your own executable programs by copying the book’s examples. It demonstrates all the Python language basics before moving on to provide examples of Object Oriented Programming (OOP) and CGI scripting to handle web form data.
🌐
Snakify
snakify.org › for loop with range
For loop with range - Learn Python 3 - Snakify
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: ... By default, the function print() prints all its arguments separating them by a space and the puts a newline symbol after it. This behavior can be changed using keyword arguments sep (separator) and end. ... print(1, 2, 3) print(4, 5, 6) print(1, 2, 3, sep=', ', end='. ') print(4, 5, 6, sep=', ', end='. ') print() print(1, 2, 3, sep='', end=' -- ') print(4, 5, 6, sep=' * ', end='.')
🌐
PyPI
pypi.org › project › steptools
steptools · PyPI
May 11, 2023 - For the past thirty years these C++ libraries have powered the product data in commercial CAD, analysis, and visualization systems and are the fastest and most reliable libraries for making, using, and manipulating STEP, STEP-NC, IFC, and CIS/2. ... License: Other/Proprietary License ( STEP Python ...
      » pip install steptools
    
Published   Jul 14, 2023
Version   20.5
🌐
Stack Exchange
stats.stackexchange.com › questions › 567024 › python-implemenatation-of-spsss-two-step-clustering
Python Implemenatation of SPSS's Two-Step Clustering - Cross Validated
March 7, 2022 - I want to perform a clustering on data with ~40 binary features. I was recommended the two-step approach by Chiu et al.. They basically use a BIRCH variant to determine pre-clusters and then perform
🌐
Python
docs.python.org › 3 › library › itertools.html
itertools — Functions creating iterators for efficient looping
1 month ago - If the input is an iterator, then fully consuming the islice advances the input iterator by max(start, stop) steps regardless of the step value. ... Return successive overlapping pairs taken from the input iterable. The number of 2-tuples in the output iterator will be one fewer than the number ...
🌐
Python
docs.python.org › 2 › library › functions.html
2. Built-in Functions — Python 2.7.18 documentation
If the start argument is omitted, it defaults to 0. The full form returns a list of plain integers [start, start + step, start + 2 * step, ...]. If step is positive, the last element is the largest start + i * step less than stop; if step is negative, the last element is the smallest start + i * step greater than stop.
🌐
Twilio
twilio.com › docs › authy › tutorials › two-factor-authentication-python-flask
Two-Factor Authentication with Authy, Python and Flask | Twilio
1 month ago - Learn how to keep you user accounts secure by using two-factor authentication (2FA) in your application with Python, Flask, and Authy from Twilio!