title: Python saving results to variables
body: <p>I am trying to loop through an array and I am checking where I have connection. (from an other function comes back a 0 or 1)</p>
  <p>The bold arrays should be my results. I want to save them to a global variable, myResults, but if I print it at the end, then I will get back a much longer array...</p>
  <p>I think the global variable is overwritten, why does it happen?</p>
  <p>Thank you :)</p>
  <p><strong>[[['A2', 'A1', 'B1', 'B2', 'B3'], 'A3'], 26]
  [[['A2', 'A1', 'B1', 'B2', 'B3', 'B4', 'A4'], 'A3'], 32]</strong></p>
  <p>[[[['A2', 'A1', 'B1', 'B2', 'B3', 'B4', 'A4', 'B4', 'C4', 'C3', 'C2', 'C1', 'D1', 'D2', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'C4', 'D4', 'C4', 'D4', 'C4', 'D4', 'C4', 'D4'], 'A3'], 26], [[['A2', 'A1', 'B1', 'B2', 'B3', 'B4', 'A4', 'B4', 'C4', 'C3', 'C2', 'C1', 'D1', 'D2', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'D3', 'D4', 'C4', 'D4', 'C4', 'D4', 'C4', 'D4', 'C4', 'D4'], 'A3'], 32]]</p>
  <pre><code>def callbackFunction(start, end, time):
      myResult = []
  
      def logToVariable(path, goal, timeFor):
          finalPath = path
          finalPath.append(goal)
          print(finalPath)
          add_result = [finalPath, timeFor]
          print(add_result)
          myResult.append(add_result)
  
      def innerLoop(start, end, time):
  
          correctList = [item for item in myList if item not in start]
          for i in correctList:
  
              first = start[-1]
              time_diff = directPoints(first, i, time)
  
              if time_diff[1] == 1:
                  if i==end:
                      #new_result = []
                      new_result =  [[start, i], time_diff[0]]
                      #logToVariable(start, i, time_diff[0])
                      # print(start, i)
                      myResult.append(new_result)
                      print(new_result)
                      #break
                      #return result
                  else:
                      start.append(i)
                      innerLoop(start, end, time_diff[0])
              else:
                  continue
      innerLoop(start, end, time)
      print(myResult)
      return myResult
  </code></pre>