TalentJR

Lesson 8

Loops - Repeating Code

Learn to repeat actions efficiently

1While Loops✨

💻 code
count = 0
while count < 5:
    print(count)
    count = count + 1  # 0, 1, 2, 3, 4

2For Loops🎯

💻 code
for i in range(5):
    print(i)  # 0, 1, 2, 3, 4

3range() Function💡

💻 code
range(5) → 0, 1, 2, 3, 4
range(1, 6) → 1, 2, 3, 4, 5
range(0, 10, 2) → 0, 2, 4, 6, 8

4Loop Examples🚀

💻 code
# Print multiplication table
num = 5
for i in range(1, 11):
    print(f"{num} × {i} = {num * i}")
💻 code
# Repeat until correct
password = "secret"
while True:
    guess = input("Password: ")
    if guess == password:
        print("Correct!")
        break  # Exit loop

5Break & Continue🔍

💻 code
break → exits loop completely
continue → skip to next iteration

🎯 Practice Challenges

Master Loops - Repeating Code by completing all 3 difficulty levels

🟢 EASY

Loops - Repeating Code - Easy Challenge

Start with the basics. Perfect for beginners!

🟡 MEDIUM

Loops - Repeating Code - Medium Challenge

Get more challenging. Build your confidence!

🔴 HARD

Loops - Repeating Code - Hard Challenge

Master this concept. Prove your skills!

🏆 Study a lesson for 2+ minutes to earn +10 TalentJR Points a day. Badges, certificates & prizes →

Ready to Master Loops - Repeating Code? 🚀

Complete the challenges, take the quiz and keep your learning streak going!