📖 Coding lessons · 3 of 4 · 5 min

Loops: repeat without rewriting

A loop repeats instructions. Print the 5 times table:

for i in range(1, 11):
    print(5, "x", i, "=", 5 * i)

range(1, 11) gives 1, 2, … 10 (it stops before 11). The indented line runs once for each number.

A while loop repeats while something is true:

count = 3
while count > 0:
    print(count)
    count = count - 1
print("Go!")

💡 If the condition never becomes false, the loop never ends: an infinite loop!

🎯 Try it

How many times does "for i in range(4)" repeat?

Contact Shuddhi

Like what you see? Take the next step.

Start small and do more whenever you are ready — everything is free to join.

  1. GiveFor you

    Donate once or every month. 80G receipt by email from ₹100.

  2. Volunteer

    Weekends on the ground or online from home. Certificate after one month.

  3. Raise funds

    Start a free campaign for a cause, a person or an NGO and share it with friends.

  4. Lead & partner

    Take on more: coordinate a team, bring your NGO on board or partner as a company.