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