clear_screen clears the terminal before showing a menu or executing a command, keeping the user’s current context easy to see. section 6.3.3
The function selects cls on Windows and clear elsewhere, then delegates the operation to the operating system with os.system. section 6.3.3
Terminal-aware clearing
import os def clear_screen(): clear = 'cls' if os.name == 'nt' else 'clear' os.system(clear) Call clear_screen() before printing menu options and again before running the selected option. section 6.3.3
import os
def clear_screen():
clear = 'cls' if os.name == 'nt' else 'clear'
os.system(clear)
Shows the complete operating-system-aware implementation of clear_screen. section 6.3.3
