-2

I am making a quiz game and I want to make it so that when ever you go to test mode it will clear your screen. I want the program to be compatible with UNIX and windows. I want it to make it so that if the system is windows, it runs cls in the terminal, and if your on Linux it runs clear. I have nothing wrong with my code, I just can find what I want to do online.

Mr Komet
  • 13
  • 5
  • Have you done any research on your own before posting this question? I just did a very quick search and the *first* hit gives the answer. – S3DEV Dec 04 '21 at 19:30

1 Answers1

0

os.name would return nt if your system is Windows, and posix if POSIX, so you can do it like this

import os
if os.name == 'nt':
    os.system('cls')
else:
    os.system('clear')
Divan
  • 38
  • 1
  • 5
  • Please don’t post answers when 1) Poster doesn’t provide evidence of trying to work out the solution on their own, and 2) when an answer already exists. – S3DEV Dec 04 '21 at 19:32