I've been having trouble clearing the console on python. I've tried to do Console.Clear() and clear() but for some reason they haven't been working.
Asked
Active
Viewed 6,669 times
5 Answers
5
I think this will help you: Click here
There are multiple ways depends on your operating system
The fastest option would be:
print("\033c", end='')
Good luck :)

Mark
- 156
- 4
-
I'm using a website called replit, and I found out how to clear the console. Thank you anyway! – May 03 '22 at 21:33
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '22 at 03:38
1
Are you using windows? Perhaps try:
import os
os.system(‘cls’)
to clear the console instead.

aquaplane
- 127
- 4
1
For MacOS and Linux:
import os
os.system("clear")
for Windows:
import os
os.system("cls")

jirassimok
- 3,850
- 2
- 14
- 23

Alaric Malikov
- 34
- 4
1
On Windows 10, I use the following code snippet:
import os
def clear(): os.system('cls')
Then, you type in clear()
. It does not produce an extra blank line at the very top. This is in contrast to the solution provided by Ryan Duffield which uses lambda (How to clear the interpreter console?). The reason for not having an extra blank line and zero when using a regular function is that the regular function returns None.

Tyler2P
- 2,324
- 26
- 22
- 31