There way I see it, there are 2 ways I think that are effective:
import os
os.system("clear||cls") # For clearing the current OS's (or online gdb's) output console
Or
print("\033c",end='') # Uses octal escape sequence "c" to clear the terminal, without a newline
Hopefully that helps.
:)