Why the argument of recursive code in 8th line is 'string[:i] + string[i + 1:]' but not 'string'
<p>It's about a permutation problem. I tried to understand the code below but feel a little confusing finally.</p>

<p>Why the argument of  recursive code in 8th line is 'string[:i] + string[i + 1:]' but not 'string'.</p>

<p>I know that 'string' argument to recursive will return RuntimeError.</p>

<p>But why?</p>

<p>permutation link: <a href="https://www.codewars.com/kata/permutations/python" rel="nofollow">https://www.codewars.com/kata/permutations/python</a></p>

<pre><code>def permutations(string):
    result = set([string])
    if len(string) == 2:
        result.add(string[1] + string[0])
    elif len(string) &gt; 2:
        for i, c in enumerate(string):
            print "1.c = %s and i is %d"%(c,i)
            for s in permutations(string[:i] + string[i + 1:]):
                print "2.string[:i] + string[i + 1:] is %s and i is %d"%((string[:i] + string[i + 1:]),i)
                result.add(c + s)
                print "3.result is %s"%result
    return list(result)
</code></pre>

<p>Note that <code>string[a:b]</code> means a <code>[a b)</code> (including <code>a</code> and excluding <code>b</code>) substring of the string. So <code>string[:i] + string[i + 1:]</code> means the whole string without <code>i</code>th character.</p>

python algorithm recursion