I need help! - Python 3

Is there a way to where when the player presses Y the console resets all printed code?

Like i want the starting screen to reset all text shown on the console and go to the next line of code

https://replit.com/@Galaxyzeke42/DDLC-The-perfect-world#main.py

Yes! You can do that in a multitude of ways.

clear = lambda: print("\033c", end="", flush=True)
clear()
from replit import clear
clear()
from os import system, name
def clear():
  if __name__ == "nt":
    system("cls")
  else:
    system("clear")
clear()
3 Likes

I personally use the last method.

In the last one, I think you meant to put name instead of __name__.

import os
def clear():
  os.system('cls' if os.name == 'nt' else 'clear')

(Also, I’d recommend never to assign lambdas to variables, use functions instead.)

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.