I got a piece of code like this
with open(r'D:\Workstuff\my-work-python-script\Auto_Tracker (dev)\retrieve_tracking.txt', 'r+') as text: #fetch all value
for index, value in enumerate(text):
if index % 49 == 0 and index != 0:
driver.find_element(By.ID,'trackItNowForm:searchSkuBtn').click()
elif index % len(text.readlines()) == 0 and index != 0:
driver.find_element(By.ID,'trackItNowForm:searchSkuBtn').click()
I'm trying to fetch all the data in my text file and if i reach the last line in the file, Simply stop the loop and move on to next function. I also want it to limit only 50 lines.
The file i'm about to fetch have only 44 lines. So i though by condition if similar to above would solve the issue. But instead i got an error
'ZeroDivisionError: integer division or modulo by zero'
I tried printing the value i need to fetch and...
for index, value in enumerate(text): #iterate through all of them first
print(f'Total Line :{len(text.readlines())}')
print(f'Index = {index}')
The Result is 'Total Line : 44\nIndex = 0' Basically, The lenght is clearly not zero so now the error got me really confused there. Anyone know what happen here?