Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 19 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
kaelynw: starting to draw a hand
1 day ago 16 Replies 2 Medals
Twaylor: Rate it :D (Took 2 days)
2 days ago 7 Replies 0 Medals
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
2 hours ago 6 Replies 1 Medal
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
2 days ago 13 Replies 1 Medal
kaelynw: tried a lil smt, the arm is off but i like the other stuff
3 days ago 27 Replies 3 Medals
kaelynw: art igg
3 days ago 14 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!