-4

If I had a code like this:

a=input('#something')
while True:
    if a == 0:
        #Stop the program here

How would I end the program?

Thanks

Bill Reason
  • 5
  • 1
  • 3

1 Answers1

2

Yes, you usually do it this way:

import sys
sys.exit()

If there's an error you can indicate that by passing a string as in sys.exit("oops!").

John Zwinck
  • 223,042
  • 33
  • 293
  • 407