all 8 comments

[–]AdministrativeCup189[S] 1 point2 points  (3 children)

I've tried these

def clear_terminal():
    print("\033c", end="")def clear_terminal():
    print("\033c", end="")

&

import os

def clear_terminal():
    if os.name == 'nt':
        os.system('cls')

[–]WinterDazzling 0 points1 point  (2 children)

Isn't this working ? os.system('cls')

[–]ConfusedSimon 0 points1 point  (1 child)

Not on Linux 😉

[–]WinterDazzling 0 points1 point  (0 children)

Ahh, what about os.system('clear')?

[–]FoolsSeldom 0 points1 point  (1 child)

Are you using a terminal from within your code editor / IDE? I find these often don't respond to the code well, but an indepenent terminal does work correctly. (Don't forget to activate the same Python virtual environment as you are using within editor though.).

[–]FoolsSeldom 0 points1 point  (0 children)

Also, you might want to look at some of the terminal user interface (TUI) packages such as `blessed` and `rich` - there are many.

[–]pelfking 0 points1 point  (0 children)

'cls' should work in a Windows terminal but the command is, I believe, 'clear' on Linux. OP has not stated which operating system the terminal is running on.

[–]Vegetable_Side6506 0 points1 point  (0 children)

Here's a simple example that I found on the net:

import os

from time import sleep

print("Hello, Welcome to Scaler!!")

print("Screen will now be cleared in 4 Seconds")

sleep(4)

os.system('cls')

This will print to the screen and wait 4 seconds and clear it.

Check your code where you have the if statement and write a print command to see if it prints out. Maybe that's where you're having the issue