Skip to content

Instantly share code, notes, and snippets.

@SZanlongo
Created September 18, 2014 01:59
Show Gist options
  • Save SZanlongo/2ee03423ace9d9412305 to your computer and use it in GitHub Desktop.
Save SZanlongo/2ee03423ace9d9412305 to your computer and use it in GitHub Desktop.
2D Matrix
# https://stackoverflow.com/questions/691946/short-and-useful-python-snippets
# Create 2-dimensional matrix
lst_2d = [[0] * 3 for i in xrange(3)]
print lst_2d
# Assign a value within the matrix
lst_2d[0][0] = 5
print lst_2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment