I feel like an idiot asking this but is doing quit()
the best way to terminate a python programme? Or is there a better way that could gradually stop all while True loops ect instead of just instantly stopping it all? Once again, I feel like an idiot asking this but I'm just curious.
I don't know why you don't want to use quit()
but you can use this:
import sys
sys.exit()
Or this:
raise SystemExit(0)
To halt a while loop you can use the break
statement. For example:
while True:
if True:
do something #pseudocode
else:
break
The break
statement will immediately halt the while
loop as soon as the else
statement is read by python
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments