Advertisement
KNenov96

matrix

Jan 29th, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. matrix = [[]] * 2
  2. matrix[0].append(2)
  3. print(matrix)
  4.  
  5. ### output: [[2], [2]] ###
  6.  
  7.  
  8.  
  9. other_matrix = []
  10. for _ in range(2):
  11.     other_matrix.append([])
  12.  
  13. other_matrix[0].append(2)
  14. print(other_matrix)
  15.  
  16. ### output: [[2], [0]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement