I want to iterate over three lists, but the number of iterations should only be range(len(dfs))
.
Where I am having trouble is figuring out the best way to structure this so that it has both a range for the number of iterations, and has multiple iterators.
dfs = [df1, df2]
sheet_tabs = ['abc', 'def']
years = [2020, 2021]
for df[x], tab[x], year[x] in zip(dfs, sheet_tabs, years):
if not df[x].empty:
df[x] = ...
what I am kind of after but think there is a better approach...:
for df[x], tab[x], year[x] in range(len(zip(dfs, sheet_tabs, years))):
The reason for using indexes is because of this question I asked: Iterating over lists produces unexpected results
for df[x], tab[x], year[x]
what's with the indexes? Why doesn't the regular (and syntactically correct) way work?