0
word1=str(input("What is your first word (or topic state, event, any word with a corresponding 'definition')\n"))
def1=str(input("What is the corresponding definition or word to the first word entered?\n"))
print(word1, def1)

I have this piece of code, as you can tell the finished result will be something of a flashcard study tool, I was just wondering, that since it is flashcards, being able to see the answer 4 lines up would not be the goal since it is flashcards.

Can I run like a clear function to erase all the prints and user input directly in the program?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

2

A way you can do a clear as stated in another question is:

import os
import subprocess

def clear():
    if os.name in ('nt','dos'):
        subprocess.call("cls")
    elif os.name in ('linux','osx','posix'):
        subprocess.call("clear")
    else:
        print("\n") * 120

Another thing you might try is using tkinter and making your flashcard in a window so it is not just in a console.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Thanks! this is awesome, is there anyway you could explain how this works, I see what looks like the program is looking for operating systems, how does that effect how the shell is cleared? – QuestionedE Nov 17 '17 at 03:06
  • The reason it looks for that is because different OS's have different ways of clearing the console. so now in this code if you are using windows then it will call a "cls" which clears the console for windows. if you are using mac(osx) then it will do "clear" which clears that console! – That One Person XboxPcGamer24 Nov 17 '17 at 03:09
  • Oh thanks! that really helps, often times people will post answers without actually helping me, so it ends up fixing my problem, even though I don't know how it works – QuestionedE Nov 17 '17 at 03:11
  • Now all you have to do is do clear() in the console and it will clear it for you! Glad I could help! – That One Person XboxPcGamer24 Nov 17 '17 at 03:13