Search code examples
pythonentercontinue

Press Enter to Continue. . . Then Delete Statement (Python)


I have a burning question i'd like to ask. I'm new to Python, and I wanted to know if there was a way where I could display my message, say for example

print("Hello World!")

Then right after have a message pop up, (preferably in a bolded font if possible)

input("Press Enter to Continue. . .: ")

but after pressing Enter, I want the program to delete the Message "Press Enter to Continue . . ." after it has been pressed, Is that even possible? Would that even happen? I just don't want the program to look like

Hello World!
Press Enter to Continue . . .
How are you doing today?
Press Enter to Continue . . .
This is a Test
Press Enter to Continue . . .

Any feedback is appreciated! I just started scripting so I apologize if this sounds ridiculous.


Solution

  • Assuming your terminal understand ANSI escape code:

    print("Hello World!")
    raw_input("Press Enter to Continue. . .: ")
    print("\033[FX X X X X X X X X X X X X X X ");
    #      ^^^^^^
    #    move up
    #            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    #            overwrite by whatever you want