Loop-Ception + Break = ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Loop-Ception + Break = ???

What happens if you put a loop within another loop and use a break statement? Would it only exit the inner loop, or exit both loops?

11th Feb 2017, 5:20 PM
SirLucidus
SirLucidus - avatar
2 Answers
+ 4
depends on where you put the break statement
11th Feb 2017, 5:25 PM
Sandeep Balachandran
Sandeep Balachandran - avatar
+ 3
A break statement exits the current loop it's in. Meaning yes, it exits the inner loop.
11th Feb 2017, 7:16 PM
John Afolayan