title: Store and Retrieve Objects from Python Lists
body: <p>I am new to python and have a difficulty getting an object to be stored and access in an array or a list in Python.</p>
  
  <p>I've tried doing something like this:</p>
  
  <pre><code>class NodeInfo:
      def __init__(self, left, value, right):
          self.l = left
          self.r = right
          self.v = value
  
  tree[0] = NodeInfo(0,1,2)
  
  tree[0].l = 5
  tree[0].r = 6
  tree[0].v = 7
  </code></pre>
  
  <p>When I try to assign values to or try to read from the variable, I get the following error:</p>
  
  <pre><code>tree[0] = NodeInfo(0,1,2)
  NameError: name 'tree' is not defined
  </code></pre>
  
  <p>What am I doing wrong, or is there a different way to assign and read objects from arrays or lists in Python.</p>