How do i clear screen in PYTHON ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do i clear screen in PYTHON ?

3rd Jan 2019, 5:42 AM
Programmer Raja
Programmer Raja - avatar
3 Answers
+ 3
First you need to import os. Then, depending on the OS, you either use os.system('clear') for Linux and Mac OS or os.system('cls') for Windows. Using cls with Linux or clear with Windows will result in an error. So you need to check for the OS too => https://stackoverflow.com/questions/1854/JUMP_LINK__&&__python__&&__JUMP_LINK-what-os-am-i-running-on
3rd Jan 2019, 6:51 AM
Anna
Anna - avatar
+ 3
Anna : Thanks , in some versions of Python also you can use Ctrl+L for clearing the screen. But It doesn't work properly in all versions or all OS.
3rd Jan 2019, 7:25 AM
Nina Lumi
Nina Lumi - avatar
0
Anna for android what I need to do
3rd Jan 2019, 7:22 AM
Programmer Raja
Programmer Raja - avatar