How do you quit out of Python when you’re in an interactive shell environment?
The easiest way to close the Python shell in Terminal is to issue the
Here’s an example demonstrating how to exit from a terminal window using the a-Shell app on the iPhone:
As you can see from the example above I was able to access the Python interactive shell by entering
on the command line. This simple instruction invokes the Python REPL and enables the user to enter Python commands.
In this example, I’ve instructed Python to output the current working directory.
To exit from the interactive shell there are a variety of ways, and in this instance I exited by using the
Here is another way of being able to exit the shell using a similar command called
Both commands perform the same operation by quitting the current interactive shell environment in a terminal window.
Use Keyboard Shortcut
There is another easier way of being able to exit the interactive shell within a terminal window and that is by using the
To use this shortcut simply hold down the
key on your keyboard and the tap the
If you have opened the Python interactive shell from within a terminal window you can try one of 3 means of exiting out from the Python shell. On a new prompt row enter the command
, or use the keyboard shortcut