Ask coding questions

← Back to all posts
how to clear screen
jmbeaner (4)

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.

Commentshotnewtop
eankeen (1385)

hey!

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

at the top of your file

import replit

to clear the screen, call the clear function

replit.clear()

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

hope i could help :P

etian (33)

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

eankeen (1385)

@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

PDanielY (1124)

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

etian (33)

@eankeen alright thanks anyway

theangryepicbanana (1652)

What language are you using?

jmbeaner (4)

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

theangryepicbanana (1652)

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