+ 1

why the break is not working? please i need help

30th Sep 2019, 3:01 PM
Unknown
6 Respuestas
+ 1
You can write while True: This means it will run unconditionally. And then you take the input IN your loop, right before the conditions. For every input, there will be the test if the loop needs to break.
30th Sep 2019, 3:26 PM
HonFu
HonFu - avatar
+ 2
break statment only works in loops. Since you don't have a loop outside of if statment. Break wouldn't do anything.
30th Sep 2019, 3:07 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
break is meant to escape from a *loop*! while condition: some code if some other condition: break You are using break for an if block, which is not what it's meant for. Also even if it worked - in your example the only content of that block is that break. So if the condition was true - you'd jump right back out anyway.
30th Sep 2019, 3:08 PM
HonFu
HonFu - avatar
+ 2
HonFu it worked well. thankss
30th Sep 2019, 4:09 PM
Unknown
0
This is not a switch statement.
30th Sep 2019, 3:11 PM
Seb TheS
Seb TheS - avatar
0
HonFu i used the while loop, but in that way it will give the answer lots of times, though the break didn't allow me to print my sentence, it simply said no output.i updated it you can see it. thanks to you anyway. really appreciated!!
30th Sep 2019, 3:23 PM
Unknown