Back
I'm trying to write a program in Python but I don't know how to clear the screen. I use both Windows and Linux and I use commands to clear the screen in those, but I don't know how to do it in Python.
How do I use Python to clear the screen?
You can use the below-mentioned code to clear the screen in Python:-
import os os.system('cls')
import os
os.system('cls')
or
os.system('clear')
To know more about this you can have a look at the following video tutorial:-
The simple way of clearing the console in Python is just pressing Ctrl+L.
However, if you want to clear the screen while implementing the code, then refer to the below that you have to run:
If you are looking for an online course to learn Python, I recommend this Python Training program by Intellipaat.
31k questions
32.8k answers
501 comments
693 users