1def clear():
2
3 # for windows
4 if name == 'nt':
5 _ = system('cls')
6
7 # for mac and linux(here, os.name is 'posix')
8 else:
9 _ = system('clear')
1As you mentioned, you can do a system call:
2
3For Windows
4>>> import os
5>>> clear = lambda: os.system('cls')
6>>> clear()
7
8For Linux the lambda becomes
9>>> clear = lambda: os.system('clear')