How to clear the screen in Python?

Do you wonder how to clear the screen in Python? This is something that I’ve been asked a lot of times, but its quite easy, I’d say.
You guys have probably tried the commands “cls” and “clear” already, but it didn’t work, did it? Not a problem. Here’s something which will work.
For Windows

import os
os.system('cls')  # on windows

For Linux

os.system('clear')  # on linux

For OS X

os.system('clear')  # on os x

Published by Abhinav Gyawali

Hello there! I'm a teenager, who spends most of his day thinking and analyzing things. I'm full of ideas and creativity! Hence, I realized a blog would be perfect for me to share my ideas!

Leave a comment

Your email address will not be published. Required fields are marked *

%d bloggers like this: