0

I have 0 experience in coding but I put my ambition and code something in python for a game. Everything works perfect :D But I have a problem. I don't know how to infinite repeat the code. I've look over the internet but i didn't understand much. Im gonna let here a part of the code maybe someone can explain me how to put all code into 'repeat'.

import time
import pyautogui
pyautogui.click(942, 642)
time.sleep(1)
pyautogui.click(807, 581)
time.sleep(1)

Thanks.

pacman
  • 1
  • 1
  • 1
    Does this answer your question? [How to run the Python program forever?](https://stackoverflow.com/questions/20170251/how-to-run-the-python-program-forever) – R. Arctor Feb 22 '21 at 17:57

1 Answers1

3

Simply wrap it all (or, well, not the imports) in a while True: loop.

import time
import pyautogui

while True:
    pyautogui.click(942, 642)
    time.sleep(1)
    pyautogui.click(807, 581)
    time.sleep(1)
AKX
  • 152,115
  • 15
  • 115
  • 172
  • Already tried this and it says Error:expected an indented block. – pacman Feb 22 '21 at 18:04
  • 2
    This is Python – you'll need to make sure the code within `while True:` is indented like in my example. – AKX Feb 22 '21 at 18:05