clear python shell in python script code example
Example 1: how to clear the console python
def clear():
# for windows
if name == 'nt':
_ = system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
Example 2: python interpreter clear screen
import os
# Windows
os.system('cls')
# Linux
os.system('clear')