</> CodeWithMe
Sign in
← 🐍 Python for Beginners

Loops

A for loop repeats code for each item of a sequence. range(a, b) gives the numbers from a to b - 1:

for i in range(1, 4):
    print("Step", i)

Output:

Step 1
Step 2
Step 3

Challenge

Using a loop, print the numbers from 1 to 5 — each on a new line.

Loading Python (about 5 seconds the first time)…