0

I am a python beginner, and I am working on an interactive shell/terminal. I want to clear screen interactively with input. Would someone help me please, figure out a cross-platform solution.

Mohamed Zouari
  • 395
  • 1
  • 5
  • 14

1 Answers1

0

Well you can do it with system Lib. If you’re using linux or mac :

system('clear')

Windows :

system('cls')

This a general function :

from os import system, name 

def clear(): 

    # for windows 
    if name == 'nt': 
        _ = system('cls') 

    # for mac and linux(here, os.name is 'posix') 
    else: 
        _ = system('clear') 
Mohamed Zouari
  • 395
  • 1
  • 5
  • 14