0

I am a beginner to Python and am having trouble with getting text to wait until the user clicks their mouse. How can I do so? what I want to do is I want to print("text") have it wait till the user clicks and then print("more text"), if that makes sense so for example:

print("More text will be printed when user clicks")

CODE THAT DETECTS USER CLICKING/WAITS FOR USER INPUT

print("More text")

I tried using time.sleep(0) thinking it would just wait for a user input. I also tried using input() but it didnt work it said somthing about 2 arguments when one was expected I am using Replit to host my code I do not want to use tkinter

D Nagesh
  • 19
  • 3

2 Answers2

1

I managed to fix it using input as

print("justsometext")
i=input("click enter")
print("evenmoretext")

instead of what i did earlier which was wrong

i=input("justsometext,click enter for more")
print("evenmoretext")
D Nagesh
  • 19
  • 3
0
pip install mouse

and then try the following :

import mouse

print("More text will be printed when the user clicks")


def on_click(x, y, button, pressed):
    if pressed:
        print("More text")

mouse.on_click(on_click)

input("Click anywhere to exit.")
Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60