In the below code , break statement is inside the if loop but while loop get terminated.why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

In the below code , break statement is inside the if loop but while loop get terminated.why?

https://code.sololearn.com/cc1z5bqIQr01/?ref=app

6th May 2020, 5:24 PM
Hari Krishna Sahu
Hari Krishna Sahu - avatar
2 Answers
+ 3
The "if" is not a loop.
6th May 2020, 5:28 PM
rodwynnejones
rodwynnejones - avatar
+ 1
The ''break'' statement terminates the closest enclosing loop. ''if'' is not a loop it is a ''statement". A loop repeatedly executes the statements enclose within it as long as the loop condition is 'True'. Whereas, a statement executes only once.
7th May 2020, 2:48 AM
vaylon fernandes
vaylon fernandes - avatar