How to generate a cartesian product of a several iterators in Python

1 Answer

0 votes
from itertools import *

for i in product([1, 2], ['a', 'b', 'c']):
    print(i)




'''
run:

(1, 'a')
(1, 'b')
(1, 'c')
(2, 'a')
(2, 'b')
(2, 'c')
 
'''

 



answered Jul 26, 2019 by avibootz

Related questions

1 answer 129 views
2 answers 298 views
2 answers 288 views
2 answers 223 views
1 answer 117 views
1 answer 130 views
...