Wait for user to press key before printing text

So where exactly would i put this?

import sys

class TerminalInput:
    def __init__(self):
        self.input_buffer = []

    def read_line(self):
        try:
            # Read a line of input and append it to the buffer
            line = sys.stdin.readline().strip()
            self.input_buffer.append(line)
        except KeyboardInterrupt:
            print("\nInput interrupted. Exiting...")
            exit(0)

    def process_input(self):
        while True:
            self.read_line()
            last_line = self.input_buffer[-1]
            if last_line.lower() == 'quit':
                break

            print(f"Output: {last_line}")

    def run(self):
        print("'quit' to exit.")
        self.process_input()

if __name__ == "__main__":
    terminal = TerminalInput()
    terminal.run()

I can do it for you, if you just send your Repl link or code. :slight_smile:

https://replit.com/@Galaxyzeke42/DDLC-The-perfect-world#VM3.py

1 Like

Alright, I will do it for you just give me like 5-10 minutes. I need to switch to my next study hall, I’m still in school. :sob:

1 Like

Im in lunch rn lol So i understand

1 Like

That’s the exact opposite of what OP wants.

@Galaxyzeke42 have you tried this?

1 Like

No, it isn’t. Please read OP message. They wanted it so that when they press a key on the keyboard, it will show up. The code I sent still meets the requirements and what’s requested. getkey() might be a better option, though, since it’s easier.

:woman_facepalming: no, that is not what OP wants. You misunderstood them.

1 Like

OHHHHH, my bad I didn’t read it all the way. :man_shrugging:

1 Like

Yes i tried that it didnt work

Does it just show the same error?

1 Like

Unfortunately it shows the same error

Oh, wait, so you want it to print something, then clear it and print the next text when someone clicks something?

I want it to work how the text in this repl works
https://replit.com/@Galaxyzeke42/ddlc-but-cpp#dialogue/dialogue.txt

1 Like

Can you invite me to your Repl?

1 Like

how do i do that???

https://docs.replit.com/programming-ide/workspace-features/multiplayer#invite-someone-to-multiplayer

3 Likes

kk there i invited you and also thank you CoderElijah!

1 Like

and im sorry for taking so long to reply i just now got off of school

1 Like

Did you finish querty?