I am trying to do
ls = [myfunc(a,b,i) for a in a_list for b in b_list]
but also pass in i
into myfunc, which is an index starting at 0 and incrementing for each new element.
For example:
a_list = 'abc'
b_list = 'def'
should result in
ls = [myfunc('a','d',0),
myfunc('a','e',1),
myfunc('a','f',2),
myfunc('b','d',3),
myfunc('b','e',4),
...
myfunc('c','f',8]
I know that I can use enumerate()
for just the normal case, ie.
ls = [myfunc(a,i) for a,i in enumerate(a_list)]
But I can't figure out how to do it cleanly when there are two for
s. I couldn't find this question posted previously either.