1import os
2
3def clearConsole():
4 command = 'clear'
5 if os.name in ('nt', 'dos'): # If Machine is running on Windows, use cls
6 command = 'cls'
7 os.system(command)
8
9clearConsole()
10
1import os
2
3def clear(): # this function will clear the console
4 command = 'cls' # cls is for windows
5 if os.name != 'nt': # if it isnt windows it will use clear
6 command = 'clear'
7 os.system(command)
8 return 0
9
10# example usage:
11name = input('whats your name?')
12clear()
13print('your name is: ' + name)