break and continue in Python TRB CSI › Python Programming › Iteration - Break, Continue

break and continue in Python

break break statement is used to immediately terminate the entire loop. தமிழில்: Loop நடந்து கொண்டிருக்கும்போது ஒரு particular condition வந்ததும் முழு loop-ஐ உடனே நிறுத்த break பயன்படும். continue continue statement skips the current itera…

Premium — locked Beginner 16 min 150 cards 10 programs 8 MCQs v3
This is a premium lesson. You can see the shape of every card — unlock to read them. Unlock

Python loops-ல் execution flow-ஐ control செய்ய break மற……

Premium This card is part of the premium lesson. Unlock
Definition

break break statement is used to immediately terminate the entire loop. தமிழில்: Loop நடந்து கொண்டிருக்கும்போ……

Premium This card is part of the premium lesson. Unlock
Simple Explanation

இதுதான் main difference: break ↓ Entire Loop STOP continue ……

Premium This card is part of the premium lesson. Unlock
Flow

break Flow Loop Start ↓ Condition Check ↓ break condition True? ↙ ↘ Yes No ↓ ↓ Loop Stop Continue Loop ……

Premium This card is part of the premium lesson. Unlock
Syntax
or
Syntax
or
Explanation
Break

1. break with for Loop…

Premium This card is part of the premium lesson. Unlock
Explanation

for i in range(1, 6): if i ==……

Premium This card is part of the premium lesson. Unlock
Explanation

for i in range(1, 6): Values: 1, 2, 3, 4, 5 First: i = 1 Condition: i == 3 False. So: print(i) ……

Premium This card is part of the premium lesson. Unlock
Dry Run

i = 1 1 == 3 → False Print 1 i = 2 2 ……

Premium This card is part of the premium lesson. Unlock
Important
Very important

இந்த program: for i in range(1, 6): if i == 3: break ……

Premium This card is part of the premium lesson. Unlock
Explanation
Break position

Compare: for i in range(1, 6)……

Premium This card is part of the premium lesson. Unlock

இங்கே print(i) first. அதனால் ……

Premium This card is part of the premium lesson. Unlock
Important
Important point

Code order matters.…

Premium This card is part of the premium lesson. Unlock
Program
Program 1
Program
Program 2
Explanation
Break with while

i = 1 while i…

Premium This card is part of the premium lesson. Unlock
Program
When

Loop completely stops.…

Premium This card is part of the premium lesson. Unlock
Real Life Example
Real time example break

Suppose password search: passwords = ["123", "abc", "Tesla36……

Premium This card is part of the premium lesson. Unlock

Once required value found, rema……

Premium This card is part of the premium lesson. Unlock
Explanation
Continue

1. continue with for Loop…

Premium This card is part of the premium lesson. Unlock
Explanation

for i in range(1, 6): if i ==……

Premium This card is part of the premium lesson. Unlock
Explanation

Values: 1, 2, 3, 4, 5 When: i = 1 condition False → print 1. When: i = 2 condition False → pr……

Premium This card is part of the premium lesson. Unlock
Dry Run

i = 1 1 == 3 → False Print 1 i = 2 2 == 3 → False Print ……

Premium This card is part of the premium lesson. Unlock
Explanation
Main difference

Same condition பயன்படுத்திப் பார்ப்போம்……

Premium This card is part of the premium lesson. Unlock
Explanation
Visual difference

Sequence: 1 2 3 4 5 break at ……

Premium This card is part of the premium lesson. Unlock
Output
Result
Output
Result
Memory Trick

Imagine school class. break Teacher says: "Class over!" Everybody stops. continue Teac……

Premium This card is part of the premium lesson. Unlock
Explanation
Continue with while

continue + while கொஞ்சம் careful-ஆக பயன்படுத்த வேண……

Premium This card is part of the premium lesson. Unlock
Common Mistake

continue with while can creat……

Premium This card is part of the premium lesson. Unlock
Output
Result
Explanation
Correct version

Update value before continue possibil……

Premium This card is part of the premium lesson. Unlock
Interview Point
Important interview point

With while + continue: Ensure the loop-control v……

Premium This card is part of the premium lesson. Unlock
Explanation
Break in nested loop

Nested loop: for i in range(1, 4)……

Premium This card is part of the premium lesson. Unlock
Explanation
Why

Outer loop: i = 1 Inner: j = ……

Premium This card is part of the premium lesson. Unlock
Important

break stops only the nearest / innerm……

Premium This card is part of the premium lesson. Unlock
TRB Point
Very important trb point

Nested loops-ல்: break all loops-ஐ ……

Premium This card is part of the premium lesson. Unlock
Explanation
Continue in nested loop

for i in range(1, 3): for j i……

Premium This card is part of the premium lesson. Unlock
Program
Each inner loop-ல்

மட்டும் skip ஆகிறது.…

Premium This card is part of the premium lesson. Unlock
Explanation
Break with search

List-ல் number search: numbers = [10, 20……

Premium This card is part of the premium lesson. Unlock
Explanation
Without break

numbers = [10, 20, 30, 30, 50……

Premium This card is part of the premium lesson. Unlock

Because loop continues checki……

Premium This card is part of the premium lesson. Unlock
Explanation
With break

numbers = [10, 20, 30, 30, 50] ……

Premium This card is part of the premium lesson. Unlock

First match கிடைத்ததும் stop.…

Premium This card is part of the premium lesson. Unlock
Real Life Example
Continue real time example

Suppose marks: marks = [80, -1, 75, 90] -1 invalid m……

Premium This card is part of the premium lesson. Unlock

Invalid value மட்டும் skip.…

Premium This card is part of the premium lesson. Unlock
Explanation
Continue to print odd

for i in range(1, 11): if i %……

Premium This card is part of the premium lesson. Unlock
Explanation

Even numbers வந்தால்: continue அ……

Premium This card is part of the premium lesson. Unlock
Explanation
Continue to print even

for i in range(1, 11): if i %……

Premium This card is part of the premium lesson. Unlock

Odd numbers skip செய்யப்படுகி……

Premium This card is part of the premium lesson. Unlock
Explanation
For else with break

Python-ல் for...else உள்ளது. for……

Premium This card is part of the premium lesson. Unlock
Explanation
Break affects else

for i in range(1, 5): if i ==……

Premium This card is part of the premium lesson. Unlock

Completed வராது. Why? Loop br……

Premium This card is part of the premium lesson. Unlock
Explanation
Continue affects else

for i in range(1, 5): if i ==……

Premium This card is part of the premium lesson. Unlock

Why? continue entire loop-ஐ terminate ……

Premium This card is part of the premium lesson. Unlock
Comparison
Break vs continue table
Comparison
Break vs pass
Real Life Example
Example

for i in range(3): pass print……

Premium This card is part of the premium lesson. Unlock

pass doesn't skip print.…

Premium This card is part of the premium lesson. Unlock
Comparison
Pass vs continue
Program
But
Important

So: pass ≠ continue pass → nothing ……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 1

break outside loop Wrong: if x == 10: break If th……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 2

continue outside loop Wrong: if x == 5: con……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 3

Thinking break exits program break does not n……

Premium This card is part of the premium lesson. Unlock
Program
Example

Loop ended. Program continues……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 4

Thinking continue restarts program No. c……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 5

Confusing continue with break break = ……

Premium This card is part of the premium lesson. Unlock
Memory Trick

B = Break = Bye Loop BREAK ↓ BYE ↓ Loop Finished ……

Premium This card is part of the premium lesson. Unlock
TRB Point

1. break is used to?…

Premium This card is part of the premium lesson. Unlock
TRB Point

Terminate a loop immediately.…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. continue is used to?…

Premium This card is part of the premium lesson. Unlock
TRB Point

Skip current iteration.…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Can break be used in for?…

Premium This card is part of the premium lesson. Unlock
TRB Point

Yes.…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Can break be used in while?…

Premium This card is part of the premium lesson. Unlock
TRB Point

Yes.…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Can continue be used in bo……

Premium This card is part of the premium lesson. Unlock
TRB Point

Yes.…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. break in nested loop termi……

Premium This card is part of the premium lesson. Unlock
TRB Point

Innermost loop.…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. continue terminates entire……

Premium This card is part of the premium lesson. Unlock
TRB Point

No.…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. break terminates whole pro……

Premium This card is part of the premium lesson. Unlock
TRB Point

No. It terminates the corresp……

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Which may prevent a loop's……

Premium This card is part of the premium lesson. Unlock
TRB Point

break…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Which moves execution to n……

Premium This card is part of the premium lesson. Unlock
TRB Point

continue…

Premium This card is part of the premium lesson. Unlock
Interview Point

Question: Difference between break and continue? break: exits the complete loop immediately. continue: skips ……

Premium This card is part of the premium lesson. Unlock
MCQ

Which statement immediately t……

Premium This card is part of the premium lesson. Unlock
MCQ

Which statement skips the cur……

Premium This card is part of the premium lesson. Unlock
MCQ

1 3 4 1. break in nested loop……

Premium This card is part of the premium lesson. Unlock
MCQ

Which statement may lead to i……

Premium This card is part of the premium lesson. Unlock
MCQ

Can break occur outside a loo……

Premium This card is part of the premium lesson. Unlock
MCQ

Does continue terminate the l……

Premium This card is part of the premium lesson. Unlock
MCQ

2 3 1. Which statement does n……

Premium This card is part of the premium lesson. Unlock
MCQ

continue transfers control to:…

Premium This card is part of the premium lesson. Unlock
Practice
Practice 1

Stop at 5 for i in range(1, 1……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 2

Skip 5 for i in range(1, 10):……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 3

Skip even numbers for i in ra……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 4

Stop when number reaches 6 i ……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 5

Skip number 3 in while i = 0 ……

Premium This card is part of the premium lesson. Unlock
Summary

Python loop control: Loop Control Statements │ ├── break │ ↓ │ Entire Loop Stop │ ├── conti……

Premium This card is part of the premium lesson. Unlock
Remember

break = Loop விட்டே வெளியே போ. cont……

Premium This card is part of the premium lesson. Unlock
Explanation
Short description

break மற்றும் continue Python-ன் loop control statements. break ஒரு for அல்லது while loop-ஐ முழுவ……

Premium This card is part of the premium lesson. Unlock
Text size
17px
Theme
Contents
Print / PDF
Program