0

I am making a clear input and I'm stuck in the clearing part. Code:

import os
clear = input("Clear run console? [Y/N]: ")
if clear == "Y":
    os.system('cls' if os.name == 'nt' else 'clear')
elif clear == "N":
    print("Okay, then.")

It doesn't do anything and gives no error message.

Beedful
  • 115
  • 2
  • 11
  • 1
    PyCharm may not use standard console but only emulate console so it may not work. Test is directly in real console/terminal. Or maybe you should check with `y` and `n` instead of `Y`, `N` - or use `clear.upper() == 'Y'` and `clear.upper() == 'N'`. Or first use `print(clear)` to see what you really get in variables. – furas Jan 02 '22 at 02:43
  • If you type `cls` or `clear` in the console, does it clear? If you can't run it, then Python can't force it. – Tim Roberts Jan 02 '22 at 02:50
  • Open “Run/Debug configuration” and add an environment variable “TERM=xterm-color” – eshirvana Jan 02 '22 at 03:17
  • https://stackoverflow.com/questions/27241268/clear-pycharm-run-window possible duplicate – Joe Jan 02 '22 at 03:18

0 Answers0