fork download
  1. def matrix_union(A, B):
  2. for a, b in zip(A, B):
  3. yield [*a, *b]
  4.  
  5. A = [
  6. [0, 0, 1],
  7. [0, 1, 0],
  8. [1, 0, 1]
  9. ]
  10.  
  11. B = [
  12. [2, 2, 3],
  13. [3, 2, 2],
  14. [3, 3, 3]
  15. ]
  16.  
  17. print(list(matrix_union(A, B)))
Success #stdin #stdout 0.02s 9352KB
stdin
Standard input is empty
stdout
[[0, 0, 1, 2, 2, 3], [0, 1, 0, 3, 2, 2], [1, 0, 1, 3, 3, 3]]