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.
Asked
Active
Viewed 220 times
1 Answers
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