Q:

clear screen python

Import os
 
os.system("clear") # Linux - OSX
os.system("cls") # Windows
14
def clear(): 
  
    # for windows 
    if name == 'nt': 
        _ = system('cls') 
  
    # for mac and linux(here, os.name is 'posix') 
    else: 
        _ = system('clear') 
8
import os
os.system('clear')
11
As you mentioned, you can do a system call:

For Windows
>>> import os
>>> clear = lambda: os.system('cls')
>>> clear()

For Linux the lambda becomes
>>> clear = lambda: os.system('clear')
4
print('\033[H\033[J', end='')
1

New to Communities?

Join the community