Skip to content
Sign upLog in
← Back to Community

How do I make my text in Python disappear when the user presses a key?

Profile icon
9751

How do I make my text in Python disappear when the user presses a key?

Answered by Bookie0 [earned 5 cycles]
View Answer
Voters
Profile icon
9751
Comments
hotnewtop
Profile icon
Bookie0

you can do this:

import os input() #makes the user press enter os.system('clear') #clears the screen (makes all the text on console disappear)

you can also make os.system('clear') into a function for easier coding:

def clear(): os.system('clear')

hope this helps! =)

Profile icon
CoolJames1610

UH COPYCAT xD

@Bookie0

Profile icon
Bookie0

how? theres only that i think, and I always put it into a function so that its easier. Plus, i added comments XD

@CoolJames1610

Profile icon
CoolJames1610

smh xD copycat :P

@Bookie0

Profile icon
CoolJames1610

i also put it in a function

@Bookie0

Profile icon
Bookie0

smh uneccessary pinging

@CoolJames1610

Profile icon
CoolJames1610

smh smh

@Bookie0

Profile icon
CoolJames1610

btw pls check my new project you dont have to

@Bookie0

Profile icon
Bookie0

which one (also you should stop pinging, especially for the person who posted this ask)


@CoolJames1610

Profile icon
CoolJames1610

oh wow.

@Bookie0

Profile icon
Bookie0
Profile icon
Bookie0

i think you can also use this:

print('\033c')

or this:

print('\x1bc')

hope this helps as well! =)

Profile icon
CoolJames1610

reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

@Bookie0

Profile icon
CoolJames1610

fine i give up xD idgaf about pinging :P

@Bookie0
@Bookie0

Profile icon
CoolJames1610
from os import system def clear(): system("clear") clear()

OR

import os os.system("clear") # whenever you want to clear the screen

Hope this helped :)

Please mark this answer if it helped