Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 11 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!
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!