How can I clean Python's IDLE window? | SoloLearn: Learn to code for FREE!


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

2/22/2020 6:25:29 AM

Leonardo Diego

2 Answers

New Answer


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')


Nice menu! You could also try TKinter.