As the question asks, why doesn\'t the below code work:
while True:
exec(\"break\")
I am executing the above in pycharm via python 3.
exec
function runs code inside a code and that means it runs out of nowhere! So, your while loop doesn't catch it. Your file is
. exec
runs on another file called
. it doesn't recognize it where are you trying to break a loop where there is not a loop. So, your code is this:
while True:
exec("break")
It should be like this:
while True:
break