Skip to content
← Back to Community
How can you clear the console
Profile icon
Lightcaster5

I want to clear my console but I don't know how.
For example, I want to print something, make a delay, clear all of that, then print something new

Heres what the code my look like:
import time

print("Hey!")
time.sleep(1)
{The clear thing}
print("How are you?")

Voters
Profile icon
JasmineSaputra
Profile icon
Calamatrizacion
Profile icon
BrandonFraser1
Profile icon
VideAndersson1
Profile icon
lyvrvn
Profile icon
HarlBall
Profile icon
Lolli0815
Profile icon
MushyAvocado
Profile icon
MingYuChen1
Profile icon
DanielYinreal
Comments
hotnewtop
Profile icon
Geocube101

Method 1:

import replit replit.clear()

Method 2:

import os os.system('clear')
Profile icon
Lightcaster5

@Geocube101 Thanks! I already tried the imort os os.system('clear') but that didn't work. The first method did!

Profile icon
bobmcbob

@Lightcaster5 use this:

import os clear = lambda: os.system("clear") #do stuff clear() #clear stuff

then you can use clear() to clear.

Profile icon
SuperKidCo

@Geocube101
I tried both methods. None worked.

Profile icon
Geocube101

@SuperKidCo Are you using windows?
if so, then you can use:

import os os.system('cls')

If you're on repl.it and it still won't work then this could be a bug or problem with your repl

Profile icon
install

@Geocube101 this is correct:import replit
replit.clear()

Profile icon
install

@Geocube101 How do you do that in HTML?

Profile icon
Geocube101

@install you're trying to clear the javascript console?
If so there is a console.clear() function that clears the JS console

Profile icon
MadCuber

@Geocube101 think he wants to clear just the HTML console, not JS

Profile icon
DionMitchell42

on replit:

from replit import clear

clear()

Profile icon
SpookyFlxme

@DionMitchell42 not working for me