fork download
  1. import sys
  2. from itertools import takewhile
  3.  
  4.  
  5. def read_matrix():
  6. return [[int(x) for x in line.split()] for line in takewhile(lambda line: line.strip(), sys.stdin)]
  7.  
  8.  
  9. a = read_matrix()
  10. print(a)
  11.  
  12. b = read_matrix()
  13. print(b)
Success #stdin #stdout 0.02s 9440KB
stdin
1 2 3
4 5 6

7 8
9 0
1 2
stdout
[[1, 2, 3], [4, 5, 6]]
[[7, 8], [9, 0], [1, 2]]