How to hide something that you already typed in Python

I am currently making a memory game in which I type a few words, and after a while the words are shuffled, and then one word is deleted and replaced with a new one. Then I would ask the user to answer which word was deleted and which word replaced that word. For example, it will print:

CAT DOG MOUSE HORSE 

And after 10 seconds, I would like these words to be hidden, shuffled and replace one word with a new word, so that it is printed, for example:

 DOG HORSE RABBIT CAT 

I understand that I can use time.sleep() so that the program pauses the execution of any other code.

It would be easier to β€œprint” the first set of words substantially and then print a new OR to replace the first printed set of words with a new one.

I'm brand new, so sorry if this is not possible.

+5
source share
1 answer

You will need a library that allows you to write screen coordinates. I wrote the doscmd-screen package for this ( http://doscmd-screen.readthedocs.org/ ) and it will work something like this:

 import screen, time scr = screen.Screen() scr.writexy(scr.left, scr.top, "CAT DOG MOUSE HORSE") time.sleep(10) scr.writexy(scr.left, scr.top, " " * scr.width) 

Note: the package was originally intended only for dos, but now also supports * nix.

+2
source

Source: https://habr.com/ru/post/1215876/


All Articles