Services Work Learn About Contact
0/10
Lesson 7 of 10

Loops

Python has two main loops: for (iterate over a sequence) and while (repeat while a condition is true). The range() function generates a sequence of numbers.

PYTHON
# For loop with range
for i in range(5):
    print(i)  # 0, 1, 2, 3, 4

# For loop with list
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print(fruit)

# While loop
n = 0
while n < 3:
    print(n)
    n += 1
🧠

Quick Quiz

Answer correctly to unlock the next lesson.

Support the mission

This learning platform is 100% free: no ads, no tracking, no paywalls. If it helped you learn something useful, you can support future lessons or donate to Doctors Without Borders, which provides emergency medical care in crisis zones worldwide.

🎉

You completed Python!

You finished all 10 lessons and quizzes. You now know the basics of Python.