A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

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

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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. ?

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.