-3

I'm learning python and in a program i want to clear the output screen (eg. first i add 2 numbers the user ask for do you want to add another number and if say yes then clear the screen and ask the third number) but when I write import clear it show erroe and when I try to download it is not downloading in vs code erroe produce { You are using pip version 20.2.3; however, version 21.3.1 is available. You should consider upgrading via the 'c:\users\shubham singh\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.}

please solve my problem so i can use that module in programming and make my program efficient

and if you have any suggestion for me related to python plz tell me

  • This only tells you don't have the last pip version, which should not affect the package installation. Does ```clear``` package even exist ? – Metapod Nov 26 '21 at 09:00
  • This one can help you: [Any way to clear python's IDLE window](https://stackoverflow.com/questions/1432480/any-way-to-clear-pythons-idle-window) – Sakshi Sharma Nov 26 '21 at 09:02
  • Probably this will help: [How to clear screen in python](https://www.geeksforgeeks.org/clear-screen-python/) – frendy wijaya Nov 26 '21 at 09:04
  • many programs (especially on Linux/Unix) don't waste time for clearing screen - this way user can see all history - and maybe this is why `Python` never had function to clear screen. – furas Nov 26 '21 at 10:48

1 Answers1

0

For now there isn't any way to clear your screen in python IDE, you can just clear the screen of the the python terminal but there is another way around

you can use:

for i in range(1,100):
    print("\n")

that prints out 100 blank lines which hides the previous results in the output window

but if you run the program in a terminal then this is best for you:

import os

def clear_screen():
    os.system("cls")

#your code here

clear_screen()

if you are on linux then change that "cls" to "clear".

POINT ONE
  • 33
  • 1
  • 7