2

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.

4 Answers 4

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 :)

Sign up to request clarification or add additional context in comments.

3 Comments

I'm using a website called replit, and I found out how to clear the console. Thank you anyway!
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.
@user18896432 have you tried glitch
1

Are you using windows? Perhaps try:

import os
os.system(‘cls’)

to clear the console instead.

1 Comment

No, im using a chromebook.
1

For MacOS and Linux:

import os
os.system("clear")

for Windows:

import os
os.system("cls")

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.