Ask coding questions

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

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.

eankeen (2174)


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


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

hope i could help :P

etian (37)

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

eankeen (2174)

@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 (2020)

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

etian (37)

@eankeen alright thanks anyway

theangryepicbanana (1697)

What language are you using?

jmbeaner (9)

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

theangryepicbanana (1697)

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