Creating 2 strings out of 1 recursively
<p>I'm trying to write a program that takes a string(stringg) apart and creates 1 string with all uppercase letters in stringg and 1 string with all lowercase letters in stringg. </p>

<p>result should be something like this:</p>

<pre><code>split_rec('HsaIm') = ('HI', 'sam')
</code></pre>

<p>This is how I have tried to write it recursively.</p>

<pre><code>def split_rec(stringg):

    if not stringg: 
        return ('')
    elif stringg[0].isupper() == True and stringg[0].isalpha() == True:
        return stringg[0] + split_rec(stringg[1:]), split_rec(stringg[1:])
    elif stringg[0].isupper() == False and stringg[0].isalpha() == True:
        return split_rec(stringg[1:]), stringg[0] + split_rec(stringg[1:])
</code></pre>

<p>But when I try it I get the error code "Can't convert 'tuple' object to str implicitly". Any kind of help is appreciated.</p>

<p>There is issue with you recursion logic and it can easily be done without recursion like:</p>

<pre><code>def split_rec(stringg):
    alphas = [x for x in stringg if x.isalpha()]
    lower = [x for x in alphas if not x.isupper() ]
    upper = [x for x in alphas if x.isupper() ]
    return (''.join(upper), ''.join(lower))
</code></pre>

python string tuples