How to clear the screen in Python easily?

Both of those solutions are solid, but if you want to avoid system-specific dependencies entirely, you can simulate clearing the screen by simply printing a lot of newlines. It’s not as elegant, but it works!

def clear_screen():  
    print("\n" * 100)  
  
clear_screen()  

This method is super lightweight and works regardless of the operating system!