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

clear screen in python

How to clear console screen in python?

3rd Feb 2018, 1:01 PM
Haider Ali
Haider Ali - avatar
10 Answers
+ 7
Exactly, because it's OS-dependent. It executes the in-built operating system command, which is available only in DOS/Windows. That's why it's better to use the multiple newlines thing.
3rd Feb 2018, 1:18 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
print('\n'*25) ;) Seriously, you can use os.system('cls') for windows or os.system('clear') fo Linux, but printing newlines is always guaranteed to work without importing any modules.
3rd Feb 2018, 1:07 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
os.system('cls') doesn't work for me :(
3rd Feb 2018, 1:10 PM
Haider Ali
Haider Ali - avatar
+ 1
remember to import os ^^
4th Feb 2018, 3:08 PM
Markus Kaleton
Markus Kaleton - avatar
0
@Markus i did import os. it doesn't either way
4th Feb 2018, 3:46 PM
Haider Ali
Haider Ali - avatar
0
if u open cmd and type cls in it, does it clear?
4th Feb 2018, 3:55 PM
Markus Kaleton
Markus Kaleton - avatar
0
@Markus it does
4th Feb 2018, 3:56 PM
Haider Ali
Haider Ali - avatar
0
weird... it does absolutely nothin? errors?
4th Feb 2018, 3:57 PM
Markus Kaleton
Markus Kaleton - avatar
0
@Markus cls clears in cmd while in python program, it doesn't work at all. it is bizzare
4th Feb 2018, 3:59 PM
Haider Ali
Haider Ali - avatar
0
hmm really weird
4th Feb 2018, 4:10 PM
Markus Kaleton
Markus Kaleton - avatar