Forums

Is there a way to clear printed text in Python 2.7?

Hey, I've been trying to create a program that would print a sentence and then clear it. Can I either clear all the print off the output or just clear the last line?

PS I am coding in 2.7

You can clear the screen by printing the appropriate control codes -- on PythonAnywhere, as it's a Linux environment, that would be

print("\033[H\033[J")

Thanks! That’s super helpful! I have a second question, how would I be able to create and control sprites?

Sorry, I learned to use Xcode and I am just starting to try to make games with python.

Unfortunately no graphical stuff will work on PythonAnywhere -- it's a text-based server environment :-(

K, that’s totally fine, I’m not doing any projects using graphics, I’m actually making a text-based game, so it’s cool.