2017-02-08 5 views

答えて

3

あなたがproductchainを使用することができます。

from itertools import product, chain 
[list(chain(*i)) for i in product(x, y)] 

#[[1, 2, 3, 'a', 'b', 'c'], 
# [1, 2, 3, 'd', 'e', 'f'], 
# [4, 5, 6, 'a', 'b', 'c'], 
# [4, 5, 6, 'd', 'e', 'f']] 

それとも、リストの内包表記を使用することができます

[i + j for i in x for j in y] 

#[[1, 2, 3, 'a', 'b', 'c'], 
# [1, 2, 3, 'd', 'e', 'f'], 
# [4, 5, 6, 'a', 'b', 'c'], 
# [4, 5, 6, 'd', 'e', 'f']] 
+0

おかげで...よく働きました – kPow989

関連する問題