Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

How do you clear the console in Python?

saltyChipps
saltyChipps

I'm trying to clear the console every time the code is run, but I don't know how.

2 years ago
You are viewing a single comment. View All
1
henryeth
henryeth

Nice basic option to answer this question, there is a handy module "os" that contains a function that will work: system(). Here is the syntax you want:

from os import system clear = lambda: system("clear") # Now you can do it at any time by simply calling: clear()

Hope this helped!

2 years ago