How can the iPython console in Spyder be cleared with code in the console? I'm looking for something I could use in a simple text game.
This method doesn't work:
import os
clear = lambda: os.system("cls")
clear()
This command does clear the console,
print("\033[H\033[J", end="")
but it causes issues with other statements in the same console input. For instance,
print("\033[H\033[J", end="")
print("Hello world!")
doesn't print Hello world.