-1

Is there any way to clear the terminal's previous output? If so, how? Here is a code example to work off of.

print "Hello..."
#Code that clears previous terminal output
print "All cleared!"

I know that there is an iOS module for the mobile app pythonista that can do this, but I am wondering how to do it on Linux.

Ethan Bierlein
  • 3,353
  • 4
  • 28
  • 42
  • @TheNotGoodAtCodeGuy what's the point? The answer is already given here [How to clear python interpreter console?](http://stackoverflow.com/questions/517970/how-to-clear-python-interpreter-console) – vaultah Apr 06 '14 at 05:38
  • @TheNotGoodAtCodeGuy why can't you just click on the link and read the answer there? – ebarr Apr 06 '14 at 05:45

1 Answers1

2

Depending on whether you are on Windows or Linux, you can do:

import os
os.system('cls')   #Windows
os.system('clear') #Linux

Example:

print 'Hello...'
os.system('clear') #or os.system('cls') for Windows
print "All cleared!"
sshashank124
  • 31,495
  • 9
  • 67
  • 76