How do I clear only part of the screen in python
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-
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