title: setting a global matrix in python
body: <p>I want to save the incoming data into an array that remember its previous array position
  <code>test.py</code></p>
  
  <pre><code>global data, in_data
  data_hold = {}
  data = 0
  
  def start_input(atm_data):
     data_hold[data] = atm_data
  </code></pre>
  
  <p>When calling twice from other  module:</p>
  
  <pre><code>test.start_input (5)
  test.start_input (6)
  </code></pre>
  
  <p>The error output is:</p>
  
  <pre><code>UnboundLocalError: local variable 'data' referenced before assignment
  </code></pre>
  
  <p>I tried to put <code>data = 0</code> inside the <code>start_input(atm_data)</code> module, but the data is input into </p>
  
  <pre><code>data_hold[0] = 5
  data_hold[0] = 6
  </code></pre>
  
  <p>I want the output to be:</p>
  
  <pre><code>data_hold[0] = 5
  data_hold[1] = 6, and so on
  </code></pre>