Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 14 Online
OpenStudy (anonymous):

how do i clear the screen in python just like we do using (clrscr) in c+? I have just started ......

OpenStudy (anonymous):

I don't know of a built in command but you could do something like: print '\n' * 70 Or stick that in a function called clrscr.

OpenStudy (anonymous):

sry. this what it comes up when i enter clrscr or print '\n' * 70 : >>> clrscr Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> clrscr NameError: name 'clrscr' is not defined >>> '\n'*70 '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' >>> print '\n'*70 SyntaxError: invalid syntax (<pyshell#10>, line 1) is there any other way. thanx in advance. ?

OpenStudy (anonymous):

Can you enter: print '\n' ? That should print one new line. If that works you can print many new lines by printing many \n's.

OpenStudy (anonymous):

Just print in Python generates a new line, i.e., for i in xrange(NUMBEROFNEWLINES): print

OpenStudy (anonymous):

Something like this may help: def clearscreen(numlines=100): """Clear the console. numlines is an optional argument used only as a fall-back. """ import os if os.name == "posix": # Unix/Linux/MacOS/BSD/etc os.system('clear') elif os.name in ("nt", "dos", "ce"): # DOS/Windows os.system('CLS') else: # Fallback for other operating systems. print '\n' * numlines

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
DoltonCarlee: R I P dolly parton
11 minutes ago 0 Replies 0 Medals
Arriyanalol: So on this pretty tuesday we loss a beautiful soul dolly parton
32 minutes ago 3 Replies 1 Medal
Mari103: How to pop out like a Jacc In the box
1 day ago 0 Replies 0 Medals
Breathless: Spooky witch but cute
1 day ago 3 Replies 1 Medal
Arriyanalol: help
1 day ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
2 days ago 5 Replies 4 Medals
Jaded012023: Please tell me what you all think of this song
1 day ago 6 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!