Counting with for
Loop over a range of numbers.
Counting with for is a free Coding for Kids lesson on CoddyKit. This is lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding for Kids learning path, and your progress syncs across the web and the CoddyKit app. The Coding for Kids course includes 4 lessons in total.
Counting Loops 🔢
Hi, number ninja! 🥷 Today we learn the for loop with range(). It is the best way to count and repeat! 🎉
The for Loop Shape 📐
A for loop looks like this: for i in range(5): then indented code below. It runs 5 times!
for i in range(5):
print("Hi! 👋")What Is range()? 🎯
range(5) gives the numbers 0, 1, 2, 3, 4. It starts at 0 and stops BEFORE 5! 🤓
for i in range(5):
print(i)Starts at Zero! 0️⃣
Computers love counting from 0! So range(3) gives 0, 1, 2. That is three numbers!
for i in range(3):
print(i)The Counter i 🔢
The i is our counter. Each loop, it holds the next number. You can use any name, but i is popular!
for i in range(4):
print("Step " + str(i))What Is str()? 🔤
To join a number with a string, we wrap it in str() to turn it into text first! 🪄
for i in range(3):
print("Number is " + str(i))Count to 10 🔟
Let us count from 0 to 9 (that is 10 numbers because we start at 0)!
for i in range(10):
print(i)Repeat a Message 📢
We do not always need i. We can just repeat a message!
for i in range(3):
print("You are awesome! 🌟")Counting Treasures 💎
Let us count treasures we collected on our adventure!
for i in range(5):
print("Found treasure #" + str(i))Birthday Candles 🎂
Light up some candles with a loop! One for each number.
for i in range(6):
print("Candle 🕯️")You Can Count! 🎉
Wonderful! Try counting from 0 to 4 and printing each number.
for i in range(5):
print(i)Quick Check 🧠
Quiz time! 🎯 What numbers does range(3) give?
Recap Time! 🌟
Super counting! 🎓 Today you learned:
for i in range(n)repeats n timesrangestarts at 0iis the counterstr()turns a number into text
You are a counting champion! 🏆
Learn Python with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 35
- Lessons
- 140
Frequently Asked Questions
Is the “Counting with for” lesson free?
Yes — the full text of “Counting with for” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding for Kids course, upgrade to CoddyKit PRO. The Coding for Kids course includes 4 lessons in total.
What will I learn in “Counting with for”?
Loop over a range of numbers. You practise Coding for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Coding for Kids?
No prior experience is required. Coding for Kids on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.
How long does the “Counting with for” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Coding for Kids lesson?
Yes. Every Coding for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why Loops Are Awesome
- Counting with for
- Repeating with while
- Drawing Patterns