There are several ways to clear the screen in Python, depending on the operating system you are using. Here are some of the common methods:
Using the os module:
import os
os.system('clear') # for linux/macOS
os.system('cls') # for Windows
Using ANSI escape codes:
print("\033c", end="")
Using the subprocess module:
import subprocess
subprocess.run("clear") # for linux/macOS
subprocess.run("cls") # for Windows
Disclaimer that you might need to run the following code in a terminal and that this might not work in a Python IDE by Pycharm.