Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
16

how to clear screen

jmbeaner
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.

3 years ago

Voters

Comments

TopNew
8
hyperupcall
hyperupcall

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

3 years ago
1
etian
etian

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

3 years ago
3
hyperupcall
hyperupcall

@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

3 years ago
3
HackermonDev
HackermonDev

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

3 years ago
1
rkel524
rkel524

@etian
"clear" works now

2 years ago
1
etian
etian

@eankeen
alright thanks anyway

2 years ago
2
FourtyCoder
FourtyCoder

I know a very simple way.
from time import sleep
import os

def cls():
os.system('cls' if os.name=='nt' else 'clear')

print('Hello, World!')
sleep(2.5)
cls()
print('Nice to meet you!')
#This is python way

6 months ago
1

What about in Python

7 months ago
1
theangryepicbanana
theangryepicbanana

What language are you using?

3 years ago
1
jmbeaner
jmbeaner

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

3 years ago
2
theangryepicbanana
theangryepicbanana

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

3 years ago
Load more