This results in printing numbers from 1 to 10.
Imagine you're counting your toys, you start at 1, and every time you say a number, it's like moving one step forward on the floor. When you reach 10, that’s when you stop. So this is like telling a robot: “Start counting from 1, and keep going until you get to 10.” Then the robot says each number out loud, just like you do!
How It Works
- The robot starts with the number 1
- It says it, then adds 1 to make 2
- It keeps doing this until it reaches 10
It’s like climbing a staircase with 10 steps. You take one step at a time, and when you get to the top, you stop.
So the robot is just following instructions, counting from 1 to 10, no magic, just simple steps!
Examples
- Printing numbers from 0 to 9 using a simple loop in a beginner-friendly way.
- A kid learns how to print numbers by using a loop in their first coding class.
Ask a question
See also
- What are infinite loops?
- How Does While loops in Python are easy! ♾️ Work?
- What are while loops?
- What is while?
- What are looping algorithms?