Reputation: 167
I wanted to iterate through two lists at the same time while also being able to increment a variable: I am able to achieve this but incrementing row manually.
for name, time in zip(Linklist, Timelist):
worksheet.write(row, col, name)
worksheet.write(row, col + 1, time)
row=row+1
Trying to see if something like this can be done:
for row, name, time in zip(Linklist, Timelist):
worksheet.write(row, col, name)
worksheet.write(row, col + 1, time)
Upvotes: 2
Views: 835
Reputation: 140256
Just use enumerate
and nested unpacking:
for row, (name, time) in enumerate(zip(Linklist, Timelist)):
Upvotes: 3
Reputation: 42746
Use itertools.count
:
for row, name, time in zip(itertools.count(), Linklist, Timelist):
...
Upvotes: 2