title: Storing the result of a for loop in a array
body: <p>I am trying to save the result of a nested for loop in a list in python. can someone tell me how to do it? 
  V is an array containing [1, 2, 3]
  while n is the length = 3
  and sq is the matrix containing swaps.</p>
  
  <p>i have tried many approaches but whenever i return the result it only gives me one element of the list. 
  any help would be appreciated. Thankyou</p>
  
  <pre><code>def Permute1(sq,v,n):
          for i in range(n):
              for j in range(n):
                  if (sq[i,j]==1):
                      temp=v[i]
                      v[i]=v[j]
                      v[j]=temp
                      print(v)
  
  
  
  results: 
  [1, 2, 3]
  [2, 1, 3]
  [3, 1, 2]
  [3, 1, 2]
  [3, 2, 1]
  [3, 2, 1]
  </code></pre>