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
Leave a Reply

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

%d bloggers like this: