Search code examples
pythonpython-idle

is their a way to close the IDLE shell if they input something


is there a way on IDLE to close the users shell if they were to enter something that would be supposed to "quit"?


Solution

  • You can use exit(0) to terminate the program, as follows:

    while True:
        i = input()
        if i == "quit":
            exit(0)
        else:
            # do something
            pass
    

    For more information about what 0 for exit() means: Difference between exit(0) and exit(1) in Python