Let's say I have multiple lists called level_1
, level_2
, level_3
.. Now I want to loop through all of them, but want to use list 1 on idx 1, list 2 on idx 2, .. My solution would be something like this:
for idx, level in enumerate(??): -- #Don't know what to insert here
if idx == 1:
print(level[0])
elif idx == 2:
print(level[1])
Is there a way to create the list name you're enumerating through dynamically? Like this:
for idx, level in enumerate(level_+idx):
print(level[0])
print(level[1])