how to clear a command line python

import os

def clearConsole():
    command = 'clear'
    if in ('nt', 'dos'):  # If Machine is running on Windows, use cls
        command = 'cls'


Here is what the above code is Doing:
1. It’s defining a function called clearConsole().
2. It’s creating a variable called command and assigning it the value ‘clear’.
3. It’s using an if statement to check if the operating system is Windows or not.
4. If the operating system is Windows, it changes the value of command to ‘cls’.
5. It’s using the os.system() function to execute the command stored in command.
6. It’s calling the clearConsole() function.