Ask coding questions

← Back to all posts
Os clear thingy
[deleted]

In python, I imported "os"

Then I did os.system('clear), and it gave me this:
'5eeb8a00ddc1e620d099cf9a_5c5a0ab69613b5c78911537c_pty': unknown terminal type.

Whats wrong?

Answered by RYANTADIPARTHI (6025) [earned 5 cycles]
View Answer
Comments
hotnewtop
RYANTADIPARTHI (6025)

Solution

there are two ways or more. But I'll tell two ways to do this. Using the os module. And the repl.it module.

  • os
import os

os.system('clear')
  • replit
from replit import clear

clear()

that's it. Your error is, you forgot a ' at the end of clear.
That should work.

FloCal35 (671)

import os

def clear():
os.system("clear")

Btw the reason it didn't work is because you forgot the end ' at the end of clear

btfuss (178)

def clear():
if os.name == 'nx':
os.system('clr')
if os.name == 'posix':
os.system('clear')

THIS WORKS FOR ALL PLATFORMS AS CHECKS FOR WHICH PLATFORM

IntellectualGuy (851)

you're missing a single quote after clear, or you could just copy paste this code:

import os
os.system('clear')

If you wanted to you could also do

from os import system
system('clear')

or you could even make a function to clear the screen, so you don't have to do it every time, and name it whatever you want, I will call the function clear

import os
def clear():
   os.system('clear')
# or
from os import system
def clear():
    system('clear')
johnnyfrancis (24)

@IntellectualGuy You Spelled Import wrong. That wouldnt do anything.

IntellectualGuy (851)

@johnnyfrancis It's just a typo, and by the way this thread is 5 months old

[deleted]

Just copy and paste this code and it should work:

import os
os.system('clear')
JackLesher (14)

Did you misspell it at all? It's "os.system('clear')", it has to be exactly that.