0

How can I clean Python's IDLE window?

I know that I can use system("cls") in C++ to clean the screen, so I was searching for the equivalent in Python but I'm not sure how to use the functions. I just don't understand. What I'm looking for is to clean the screen once the user selected an option. print("Hola! Soy Leonardo jaja y este es mi primer programa espero que te guste") print("Presiona cualquier tecla para continuar: ") enter = input("") #Here I want to clean the screen :( print("Bienvenido, esto es una calculadora que realiza sumas, restas, multiplicaciones y diviiones.") print("1.- Suma") print("2.- Resta") print("3.- Multiplicación") print("4.- División") print("5.- Cerrar programa") I would apreciate so much your help <3

22nd Feb 2020, 6:25 AM
Leonardo Diego
Leonardo Diego - avatar
1 Odpowiedź
+ 2
If you are running the python program on shell on PC, you can put this in the code import os #put at starting of code os.system('clear') #For Linux users os.system('cls') #For Windows users If you are running code on IDE... then this won't work. You have to put os.system('cls') etc. everytime where you want to clear the screen. Or you can just define a function and call it everytime. def clear(): os.system('cls')
22nd Feb 2020, 6:31 AM
Utkarsh Sharma
Utkarsh Sharma - avatar