Skip to content

Instantly share code, notes, and snippets.

@mu-777
Last active August 29, 2015 14:20
Show Gist options
  • Save mu-777/f0c9c8554c15edb15660 to your computer and use it in GitHub Desktop.
Save mu-777/f0c9c8554c15edb15660 to your computer and use it in GitHub Desktop.
MAT_SIZE = 3
mat = [[0 for i in range(MAT_SIZE)] for j in range(MAT_SIZE)]
# >>> mat
# [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i, j in [(i, j) for i in range(MAT_SIZE) for j in range(MAT_SIZE)]:
mat[i][j] = 10*i + j
# >>> mat
# [[0, 1, 2], [10, 11, 12], [20, 21, 22]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment