0
Everytime i write a code using break and continue statements i get an error that the break statement is outside loop, what wrong
8 Answers
+ 2
Here is how you should do it. I've explained your problem in the code.
https://code.sololearn.com/ch4gRDABB8Uk/?ref=app
+ 8
If you want help with a particular bit of code, you can save it in the Code Playground and share it so we can check it out (three dots joined by 2 lines in the corner -> share -> copy to clipboard -> paste in Q&A with your question)
+ 8
If you want to print the numbers from 0 to 15, use
'while k <= 15:'
If you want to print the numbers from 1 to 15, either start with k = 1 or put print(k) after k =+ 1.
You don't need the if statement or the break command because a 'while' loop breaks automatically as soon as the condition is no longer True. That's why you use it đ
+ 6
@kiumi That's what I was referring to. If you remove the last 2 lines you get the same result đ
0
check it out
0
David Ashton and Ammar Darwish check out the answer given by rusev, thats what i wanted. Anyway thanks to all of you.
0
yeah, i get ur point