computer4kids is now ComputerLeap. Same free lessons, same team. Read why we changed our name

← All lessons · 🧑‍💻 Coding Academy

🧱

🎓

⏱ 15 min

Free

Blocks & Loops

Place block after block with a loop. Build a wall in seconds, not hours.

🎯 What you will learn

  • A loop repeats a build step
  • The number of repeats sets the size
  • Patterns repeat in games and in code

👋 Let’s get started!

In Minecraft you place one block at a time. A loop can do the placing for you! Tell it what to place and how many times, and it builds the whole row. ⛏️

🪜 Step by step

1. 🧱 One block

Placing one block is a single command.

print("Placed a stone block")
2. 🔁 Many blocks

A loop places the same block many times.

for i in range(4):
    print("Placed a stone block")
3. 🔢 Count it

range(4) repeats 4 times. Change the number to make a longer wall.

for i in range(6):
    print("Block", i + 1)

🧪 Try it!

Change the code and press ▶ Run to see what happens. You can’t break anything!

Build a wall

for i in range(5):
    print("Placed a block #", i + 1)
print("Wall finished!")

🎨 Unplugged activity

🧱 With LEGO or wooden blocks, build a wall 5 blocks long. Count your moves out loud as a loop: “one, two, three, four, five”. Then build one 8 long!

Build a tower

for floor in range(3):
    print("Placed floor", floor + 1)
print("Tower complete")

📖 Key words

Tap a card to flip it over!

Loop
Repeats a build step 🔁
range()
Counts how many times to repeat 🔢
Block
One piece of the world 🧱

🏆 Challenge

Build a 3-block wall: print “Placed a block” three times using a loop. Press ▶ Run.

Challenge

Knowledge Check Quiz

  1. How many times does range(4) repeat?
  2. What makes a longer wall?
  3. What is a loop good for in building?
Next lesson →