How to clear Python shell

To clear the Python shell, you can use the following command:

import os
os.system('cls' if os.name=='nt' else 'clear')

This command works on both Windows and Unix-based systems.

Alternatively, you can simply type Ctrl+L on your keyboard to clear the Python shell on most systems.

Note that clearing the shell will not affect any variables or functions you have defined in the Python environment. It only clears the display of the shell.