+ 2

how to clear screen in python shell windows 10?

clear , clear() and os.sytem('cls') not working

4th Jun 2018, 2:19 PM
Nishant Shrimali
6 Answers
+ 13
Kuba Siekierzyński šŸ˜‚šŸ˜‚šŸ‘
4th Jun 2018, 2:42 PM
AliRą«Æza
AliRą«Æza - avatar
+ 6
If you want your code to run both on Linux and Windows use this šŸ‘‰ import os # using ternary operator šŸ‘‡ os.system('cls' if os.name=='nt' else 'clear') šŸ˜Š
4th Jun 2018, 4:38 PM
OR!ON šŸ›”ļø
OR!ON šŸ›”ļø - avatar
+ 5
print('\n'*40) # ;)
4th Jun 2018, 2:36 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
Nishant Looks like you didn't import os first! šŸ˜® # First import os module šŸ‘‰ import os # Then use šŸ‘‡ os.system('cls') # if you are on Windows else use 'clear' šŸ‘ˆ šŸ˜‰
5th Jun 2018, 5:33 AM
OR!ON šŸ›”ļø
OR!ON šŸ›”ļø - avatar
+ 2
import os os.system('cls') # on windows or os.system('clear') # on linux / os x
4th Jun 2018, 2:20 PM
ā€ŽĀ ā€ā€ā€ŽAnonymous Guy
0
error : name 'os' is not defined
5th Jun 2018, 5:19 AM
Nishant Shrimali