1

I'm using Windows 10, Python 3.8. I'm trying to clear everything in my shell, but the code that I'm using doesn't seem to work.

This is my code:

import os
print("Erase This Text")
os.system('cls')
os.system('clear') #This is used for Linux, but I tried it just incase
martineau
  • 119,623
  • 25
  • 170
  • 301
itsanantk
  • 264
  • 1
  • 9
  • The `os.system('cls')` should work on Windows. See answers to [How to clear the interpreter console?](https://stackoverflow.com/questions/517970/how-to-clear-the-interpreter-console) – martineau Apr 28 '20 at 00:35

1 Answers1

0

At my Windows 10 with python 3.8, your code works! Both, cmd and powershell

But you can try some workaround, just printing blank lines, this will lead your cursor to below of your screen and data will be blank, because it will pass cmd height

def cls(height=100):
    [print() for _ in range(height)]

But if you want to solve it, the right way, maybe you should check your cmd settings for text encoding.