While loop - Break | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

While loop - Break

When using a while loop, and then using a break command, does the original if statement need to transition from true, to false and then to true again to restart the loop? What would be the advantage to this rather than putting more conditions into the if statement? Thanks!

6th Jul 2017, 1:20 PM
Ian
3 Answers
+ 3
I'm agree with @DK's: if you need to break a loop and do it again as soon you've breaked it, you need to use the 'continue' statement (wich break only the actual iteration, not the entire loop, contrarly to the 'break' statement)...
7th Jul 2017, 6:29 AM
visph
visph - avatar
+ 1
depends where you are putting that Break statement .
6th Jul 2017, 9:09 PM
Mohamed Raouf
Mohamed Raouf - avatar
0
I did a little more reading I think I understand a bit better, thanks for the replies!
7th Jul 2017, 2:22 AM
Ian