There are multiple solutions to clearing the Python interpreter.
With the os
module, the code is as follows:
import os
os.system("clear")
The os.system()
function will perform the applicable shell command with the default interpreter, often as /bin/sh
.
To install the clear
module:
pip install clear
After the clear
module is successfully installed, the initial functions will be clear.clear()
and the os
module functions wrapped under clear.os
. To clear the interpreter, you must type clear.clear()
(with no arguments).
On a terminal emulator (most likely not on IDLE, which is not a terminal interface):
Control-L (^L
)