clear
How do I clear only part of the screen in python
InvisibleOne
what part of the screen do you not want cleared?
Bookie0
Using this:
import os os.system('clear') # clears all of the console (black part)
You can use it whenever you want, or put it into a function:
import os def clear(): # defining the function os.system('clear') clear() # calls the function, and clears console
This will clear everything on the console, so if your wanted certain parts of your console cleared, that won't be possible unfortunately.
You could always just re-print
the stuff you want to keep on the console, ie:
import os def clear(): os.system('clear') # if you just want 'Hello there!' to be cleared # but you want 'How are you?' to stay # you could maybe output it again, but it would be kinda troublesome print("Hello there!") print("How are you?") clear() # clears everything from console print("How are you?") # outputs 'How are you?' again (change it to what you want to remain) name = input("Enter your name ") # an input asking for your name
Coder100
You can't. You can only clear all of the screen or none of the screen.
import os def clear(): os.system("clear") print("Hello,") input() clear() print("World!")
Michael8910
if you want to clear the output un-manually you can put print("\033c")
Do you mean only one part? If that's what you mean, then you can't do it. THe entire screen has to be cleared.
or
Any of them should work
clear()
won't just work like that, you have to put it in a function first