Home / Python Loops / How to Loop Through a Set of Code in Python In this example we will show how to loop through a set of code a specified number of times and specify a starting value in Python. Source Code for i in range(2, 4): print(i) Output: 2 3