title: How can I avoid this "variable referenced before assignment"?
body: <p>Ran into the following problem. It's probably a simple solution, and has probably been asked here before, but I couldn't find it.</p>
  
  <pre><code>def a():
      liA = []
      def b():
          for i in liA:
              i += 1
          liB = generateList()
          for i in liB:
              i -= 1
          liA = liB
  
      def generateList():
          return [1,2,3,4]
  
      b()
  
  a()
  </code></pre>
  
  <p>UnboundLocalError: local variable 'liA' referenced before assignment                </p>