Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

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?

2 Answers

0 votes
by (106k points)

You can use the below-mentioned code to clear the screen in Python:-

import os 

os.system('cls') 

or

os.system('clear') 

To know more about this you can have a look at the following video tutorial:-

0 votes
by (108k points)

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.

Related questions

0 votes
1 answer
asked Sep 10, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
4 answers
0 votes
1 answer
asked Jul 14, 2020 in Python by ashely (50.2k points)

Browse Categories

...