Skip to content
← Back to Community
How do you clear text you print in python
Profile icon
nahu1

How do you do that Pls help

Voters
Profile icon
Aaron88
Profile icon
Bushcamper8903
Profile icon
nahu1
Comments
hotnewtop
Profile icon
Coder100

ez

first, define this little function:

import os def clear(): os.system("clear")

so now, all you have to do is call the function if you want to clear it, for example:

import time print("Hello,") time.sleep(1) clear() print("World!")
Profile icon
RYANTADIPARTHI

Solution

there are 2 ways to do this. you can use the os module for this, or the replit module.

  • os
import os os.system('clear')

or

  • replit
from replit import clear clear()

like that.
That should work

Profile icon
[deleted]

Have a look at this repl. It shows how to use the clear method from the replit module: https://repl.it/@malvoliothegood/clearingtext#main.py

Profile icon
programmeruser
print('\033[H\033[J')
Profile icon
19wintersp

You can use a system command to clear the console, which can be executed using the os module. To clear the console, you use "clear" on Linux (which is used on Replit):

from os import system system("clear") #clears the screen

Or "cls" on Windows:

from os import system system("cls") #clears the screen
Profile icon
Dart

please dont spam in your description! i edited the post for you.