Ask coding questions

← Back to all posts
how to clear screen
jmbeaner

Does anyone know how to clear the screen during the code?
a clear command would be very useful to my program and I don't know one.

Voters
MichelleOvalle
JDarnley
sumamanranprai
DanielFettig
NishithaSatish
dfnk
jmbeaner
Comments
hotnewtop
eankeen

hey!

because you are using python, it is pretty easy to do this

at the top of your file

to clear the screen, call the clear function

if you want to see this in action, i forked a repl (credit to @jamiebally) here

hope i could help :P

etian

@eankeen do you know how to do this in c++? :)

eankeen

@etian i dont believe the usual way peopls use to clear the screen in c++ work in repl (i havent actually tried it myself, this is what i heard). this is why you have to import the replit module in python - i dont think there is a similar thing for c++ :P

HackermonDev

@eankeen In python you can also import system and do system("cls") and it should clear the console

rkel524

@etian "clear" works now

etian

@eankeen alright thanks anyway

theangryepicbanana

What language are you using?

jmbeaner

@theangryepicbanana I am using python... I should have specified that. My bad

theangryepicbanana

@jmbeaner try print("\x1b[2J\x1b[H", end="")