title: Python beginner confused by a complex line of code
body: <p>I understand the gist of the code, that it forms permutations; however, I was wondering if someone could explain exactly what is going on in the return statement.</p>
  
  <pre><code>def perm(l):
      sz = len(l)
      print (l)
      if sz &lt;= 1:
          print ('sz &lt;= 1')
          return [l]
      return [p[:i]+[l[0]]+p[i:] for i in range(sz) for p in perm(l[1:])]
  </code></pre>