1

I wrote a program in python and it works fine but,the problem was every time it runs it takes the user input until the while loop was true.Due to this my console fills up and it looks like mess.What should i need to do in order to clear my console every time it takes input from the user and i need it to be done from the python script.

Is there anyway?

I searched for it but,there is no use.can anyone help me to get out of this problem?

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
NAIDU
  • 169
  • 7
  • 1
    Would you please share the code or the output in the console? – The Singularity Jan 08 '21 at 09:48
  • 1
    Look here: [Any way to clear python's IDLE window?](https://stackoverflow.com/questions/1432480/any-way-to-clear-pythons-idle-window) – AcK Jan 08 '21 at 10:06
  • No. The IDLE Shell can take hundred of thousands of lines (shorter than, say, 80 chars) without 'filling up'. You can add a few blank lines before each user input. IDLE is primarily meaning for learning and developing code, and for that, being able to scroll up and see previous input and output is sometimes useful. – Terry Jan Reedy Jan 09 '21 at 02:24

2 Answers2

0

you could use the os module like this:

on windows:

import os
os.system('cls')

on linux:

import os
os.system('clear')

the os.system() method executes the command given, so if you execute the clear command it will clear the shell as you need

Ax34
  • 123
  • 7
0

There is no way you can clear IDLE's shell from my knowledge.

The best thing you're going to get to clearing the shell is using this code:

print("\n" * 100)
Expliked
  • 101
  • 10