0

So i have List one:

NumberOfLoops = 5
for x in range(1, NumberOfLoops + 1):
    listSONO.append(f'{BaseSONO}-{x:0>2}')

Output:

['AutoSO_May042022-01', 'AutoSO_May042022-02', 'AutoSO_May042022-03', 'AutoSO_May042022-04', 'AutoSO_May042022-05']

List two:

tote = ['T' + "%.5d" % i for i in range(1, NumberOfLoops + 1)]

Output:

['T00001', 'T00002', 'T00003', 'T00004', 'T00005']

i trigger a for loop by using the items on the first list but i dont know how to use corespoding items from the second as variables in the loop

For instance

Use AutoSO_May042022-01 in field xyz and T00001 in field abc and repeat that for as many times the number of items in the first list.

Thank you in advance!

EDIT: I'm sorry ill try to clarify because i see i didn't explain it well enough:

Say list1 are my logins and list2 are the passwords i would like to circle through all Logins and all Passwords 1 by 1. So send those items to a variable i have in my code that is responsible for the txt i input in the "Password" and "Login" respectfully.

So how do i make for example first loop where: a = AutoSO_May042022-01 (first position on first list) b = T00001 (first position on second list) Second loop where: a = second position on first list b = second position on second list

and so on

  • It's not clear how you want to combine the two lists. Use `zip()` to loop over them in parallel, use nested loops or `itertools.product()` to get a cross product. – Barmar May 04 '22 at 14:41

1 Answers1

-1

As far as I understood, you want to iterate through both lists simultaneously. For this you can use zip().

for f, b in zip(foo, bar):
    print(f, b)

This question is answered here How to iterate through two lists in parallel?