I have a bunch of references for different filenames at the start of my code:
_file1_="filename1"
_file2_="filename2"
_file3_="filename3"
_filew1_="anothername1"
_filew2_="anothername2"
_filew3_="anothername3"
etc
I want to make a simple pyautogui loop using:
for x in range(1, 3): #for changing _file_ and _filew_ number each loop
but whenever I try to add str(x)
to:
pyautogui.typewrite(_file_)
in any way, it stops seeing 'file' and 'filew' as a references (unresolved reference)
I started coding recently, and I know I can technically just copy / paste my code a bunch changing the number manually each time when file or filew is referenced, but copying it 30+ times is an incredibly dirty solution and would be several thousand lines long
So I'm wondering, what am I doing wrong, and is this the correct way to approach a loop?
@BrokenBenchmark (reprex)
import pyautogui
#filename list
_file1_="filename1"
_file2_="filename2"
_filew1_="filename-w-1"
_filew2_="filename-w-2"
for x in range(1, 3): # I want to be able to increase the number for the refference each loop, but i don't know any way to have it iterate it properly without breaking the references
pyautogui.typewrite(_file1_) # increase the number each loop somehow using the "range function"
pyautogui.typewrite(_filew1_) # increase the number each loop somehow using the "range function"
for now i'm just using a workaround:
#loop1
pyautogui.typewrite(_file1_)
pyautogui.typewrite(_filew1_)
#loop2
pyautogui.typewrite(_file2_)
pyautogui.typewrite(_filew2_)
but the problem here is that each loop is around 300 lines long and i have over 30 loops, but it works, was just wondering if i can somehow implement a loop here to make the code nicer