Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Clearing the console in python

I want to clear console by entering ‘0’ in the ‘istep’ or ‘ito’ but in only works when I enter ‘0’ in the ‘ito’…can somebody fix this and explain what is the reason of this behavior?THANKS!

import os

while True:
   ifrom=int(input("From: "))
   istep=int(input("Step: "))
   ito=int(input("To: "))

   if istep==0 or ito==0:
       os.system('cls')

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You need to use several if conditions, as ito only gets a value after user inputs something for istep:

import os

while True:
   ifrom=int(input("From: "))
   istep=int(input("Step: "))
   if istep==0:
       os.system('cls')
   ito=int(input("To: "))

   if ito==0:
       os.system('cls')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading