What is the best way to use a two value pair as a key in python?
<p>I am basically attempting to use a matrix in pythons. I have heard about things like a list of lists, but I wasn't sure what the easiest way to manipulate these values would be. I would essentially want there to be a value stored at coordinates (x,y) on a grid, that could only be accessed by having both x and y. Something like:</p>

<pre><code>x = 3
y = 4
Matrix[3][4] = value
</code></pre>

<p>You can store a tuple of (x, y) as a key in the dictionary:</p>

<pre><code>matrix = {(1, 1): value1, (1, 2): value2, ...}
</code></pre>

<p>You can retrieve a value associated by a coordinate like follows:</p>

<pre><code>value = matrix[(1, 2)]
</code></pre>

python list matrix