Alternate for range in python
<p>If I have to generate natural numbers, I can use 'range' as follows:</p>

<pre><code>list(range(5))
</code></pre>

<p>[0, 1, 2, 3, 4]</p>

<p>Is there any way to achieve this without using range function or looping?</p>

<p>Based on Nihal's solution, but returns a list instead:</p>

<pre><code>def recursive_range(n):
    if n == 0:
        return []
    return recursive_range(n-1) + [n-1]
</code></pre>

python