Lesson 4: Loops
Often in computer science we need to do the same thing many times. Instead of writing code 100 times, we use a Loop.
The most common is the for loop.
The For Loop
Repeats a block of code for every item in a list or for a number of times.
for i in range(5):
print("Lap number", i)
Your Objective
Use a for loop to count from 0 to 4.
- The code is already partially set up.
- Click "Run" to see how fast the computer counts!
- Try changing the number inside
range()from 5 to 10.