Recursion: design a recursive function called replicate_recur which will receive two arguments:
<p>The below code is a recursive function which takes two arguments and return something  like <code>[5,5,5]</code>.</p>

<pre><code>def recursive(times, data):  
    if not isinstance(times,int):  
         raise ValueError("times must be an int")  
    if not (isinstance(data,int) or isinstance(data, str)):  
        raise ValueError("data must be an int or a string")  
    if times &lt;= 0:  
        return []  
    return [data] + recursive(times, data - 1)  

print(recursive(3, 5))
</code></pre>

<p>Why is the code throwing a recursive error?</p>

<p>You can use a list to store the result of current recursive call.</p>

<pre><code>def replicate_recur(times, data, ret=None):
    if not ret:
        ret = []
    ret.append(data)
    times -= 1
    if not times:
        return ret
    return replicate_recur(times, data, ret)
</code></pre>

python recursion