Drama Naskah Komedi 7 Orang (2 Cowok 5 Cewek) Orang Berkontribusi 5 Orang . abap performance tuning by hermann gahm , .
Orang Berkontribusi 6 Orang, Bahasa Inggris, Konten, Pertemuan, Kerja Keras, Kumpulan Contoh, Kumpulan kumpulan contoh naskah. Naskah-naskah-naskah.
Apr 23, 2020
cherry 7d058c8ba6
naskah-drama-komedi-6-orang-7-orang-untuk-durasi-10-menit.
Category:Esperanto literatureQ:
How to get the Cartesian product of two lists in Python?
I have two lists
A = [a, b, c]
B = [1, 2, 3]
I want to get a list of all possibilities
[(a,1), (a,2), (a,3),
(b,1), (b,2), (b,3),
(c,1), (c,2), (c,3)]
How can I do this?
A:
from itertools import product
A = [1,2,3]
B = [2,3]
print(list(product(A,B)))
Output:
[(1, 2), (1, 3), (2, 2), (2, 3), (3, 2), (3, 3)]
A:
You can use itertools.product()
>>> from itertools import product
>>> A = [1, 2, 3]
>>> B = [2, 3]
>>> for a, b in product(A, B):
... print a, b
...
1 2
1 3
2 2
2 3
3 2
3 3
You can just put the items in a list and put it on one line:
>>> for a, b in product(A, B):
... print a, b
...
1 2
1 3
2 2
2 3
3 2
3 3 be359ba680
Related links:
Commentaires