Clear Screen In Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Clear Screen In Python

How do I go about clearing the screen in python. In MS DOS it’s just cls, is there something like this for python?

13th Mar 2019, 1:27 PM
DandyOrang
DandyOrang - avatar
2 Answers
+ 4
import os def clear(): os.system('cls' if os.name=='nt' else 'clear') clear() If you do it as lambda it will return/display zero https://stackoverflow.com/questions/517970/how-to-clear-the-interpreter-console
13th Mar 2019, 1:43 PM
Joshua Bailey
Joshua Bailey - avatar
+ 2
You can use os.system('cls') to use system functions like that... but it would depend on your environment if it works or not.
13th Mar 2019, 1:35 PM
HonFu
HonFu - avatar