Lesson 07 � Logic

REPEAT KARO.
SOCH SAMJH KAR.

Ek student ka result print karna easy hai. 500 students ka✓ Same instruction ko manually copy karna bad idea hai. Loop ek controlled repeat mechanism hai�aur control hi important word hai.

? 25 min✓ BeginnerPrerequisite: Lists & conditions

FOR: collection ke har item par kaam

Jab aapke paas list, string ya kisi ordered sequence ke items hain, for natural choice hai. Loop variable har turn mein current item hold karta hai.

python
skills = ["Python", "SQL", "Pandas"]

for skill in skills:
 print("Learning:", skill)

Read it literally: �skills mein har skill ke liye, Learning + skill print karo.� skill variable sirf loop body ke context mein current value ko describe kar raha hai.

range(): fixed number of repeats

range(3) values 0, 1, 2 deta hai. End value included nahi hoti. Count ka intent clear ho to range(1, 4) readable ho sakta hai�1, 2, 3.

python
for day in range(1, 4):
 print(f"Day {day}: practice complete")

WHILE: jab end condition se decide ho

while tab tak run karega jab tak condition true hai. Ismein update line mandatory socho�warna condition kabhi false nahi hogi aur infinite loop ban sakta hai.

Try it: progress counterCounter aur condition change karke observe karo
Run Python dabayein

break aur continue kab?

Quick check

List items ke har item ke liye loop shuru karne wali line likho.

for, temporary variable, in, list name aur ending colon.

Debugging checklist

Repeat ka control samajh aa gaya?

Ab frequently repeated blocks ko named reusable function mein pack karte hain.