+ 1
why the break is not working? please i need help
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.
+ 2
break statment only works in loops. Since you don't have a loop outside of if statment. Break wouldn't do anything.
+ 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.
+ 2
HonFu it worked well. thankss
0
This is not a switch statement.
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!!