0

I need to clear the screen of python.

This is the coding screen I need to code it with:

Here is the code

And the window that opens when I press "run" and "run module" is what I need to clear

I have said this in the way I did so not to cause any confusion. I am NOT using the black code runner (The one with the black background).

import os
os.system("cls")

That does not work as it just opens and immediately closes the black code runner

I am using Windows and python version 3.4.3

braX
  • 11,506
  • 5
  • 20
  • 33
  • What IDE are you using? Python itself does not have "run" or "run module" buttons (or even a screen). – jwodder Nov 04 '16 at 20:03
  • Ifyou look at the picture at the top there is the "run" button –  Nov 04 '16 at 20:03
  • 1
    That looks likt Tk, post the code you use to generate the window. – kabanus Nov 04 '16 at 20:03
  • Wait, __the black code runner__???!! Do you mean _'the console'_? – ForceBru Nov 04 '16 at 20:05
  • i would assume so – rassar Nov 04 '16 at 20:06
  • Subprocess also does not work –  Nov 04 '16 at 20:07
  • 1
    what do you mean by "closes the black code runner"? Command Prompt? Console? Terminal? Is there some specific IDE you are using? – Moinuddin Quadri Nov 04 '16 at 20:08
  • 1
    Note: Stack Overflow is *not the place* for urgent requests. We are building a repository of knowledge for the long term, with quality questions and even better answers. The word 'urgent' has no place in such questions. – Martijn Pieters Nov 04 '16 at 20:09
  • Thanks for telling me should I remove that from the title? –  Nov 04 '16 at 20:10
  • I've already done so for you. You are using IDLE, so I duped you to the canonical question on how to clear the IDLE shell. – Martijn Pieters Nov 04 '16 at 20:12
  • I am trying to avoid adding lots of new lines @MartijnPieters –  Nov 04 '16 at 20:14
  • That is all that works from that other question therefore there is no correct answer for this question there @MartijnPieters –  Nov 04 '16 at 20:15
  • @Programmingmann: Are you actually calling the `import os; os.system('cls')`? Share with us the complete code where you used it? Because I do not see it in the current code – Moinuddin Quadri Nov 04 '16 at 20:17
  • Yes I did use that code @anonymous –  Nov 04 '16 at 20:18
  • But the question is where? It will be helpful if you can paste your complete code over here – Moinuddin Quadri Nov 04 '16 at 20:19
  • I have haven't I? If you don't think so can you please edit the question to show that please @anonymous –  Nov 04 '16 at 20:21
  • The code where you have written `os.system('cls')`. Am I missing anything? In your code I can only see `print()` and `input()`. Do you expect me to hack into your machine, copy the code and paste it over here? – Moinuddin Quadri Nov 04 '16 at 20:22
  • Also why have you still got this marked as duplicate @MartijnPieters I have already told you I have looked and the answer is not there. It only suggests adding lots of new lines which I do not wish to do - It is not "actually clearing the screen" –  Nov 04 '16 at 20:23
  • Oh yes sorry @anonymous the image. I will add the correct image in now –  Nov 04 '16 at 20:23
  • @Programmingmann: this is the same question. If there is no satisfying answer there you won't find one here either. – Martijn Pieters Nov 04 '16 at 20:24
  • @MartijnPieters Please can you unmark this as duplicate and give this question a chance incase anyone new sees this and finds an answer –  Nov 04 '16 at 20:27
  • @anonymous How is that? –  Nov 04 '16 at 20:29
  • @MartijnPieters Plese open this post again, someone may have the correct answer that I am looking for but cannot post it, plus it is still not a duplicate. If you still think it is please explain why –  Nov 04 '16 at 20:37

1 Answers1

0

It appears from your code that you forgot to import the os module first, add this at the beginning of the file:

import os

Edit: it may have to be os.system('cls')

Edit2: After some testing around it looks like the default Python interpreter accepts:

import subprocess
subprocess.call("cls", shell=True)
SpaceW189
  • 16
  • 4