0

I have a line of code with a number. The code is copypasted multiple times so it can run many times. The problem is the numbers don't change. I am using pyautogui so the following is an example.

import pyautogui

pyautogui.typewrite("Hello")

pyautogui.scroll(1)

pyautogui.typewrite("Hello")

pyautogui.scroll(1)

pyautogui.typewrite("Hello")

pyautogui.scroll(1)

On the second and 3rd pastes of the code, how can I have them automatically be 2, 3 etc?

Dhaval Taunk
  • 1,662
  • 1
  • 9
  • 17
  • Hey Jaiden, have you tried a for loop? `for i in range(2): pyautogui.typewrite("Hello") pyautogui.scroll(i)` – Emil Jun 17 '20 at 09:10

1 Answers1

1

Use a loop.

for i in range(1, 4):
    pyautogui.typewrite("Hello")
    pyautogui.scroll(i)
timgeb
  • 76,762
  • 20
  • 123
  • 145