Reverse a list without using built-in functions
<p>I'm using Python 3.5. </p>

<p>As part of a problem, I'm trying to design a function that takes a list as input and reverts it. So if <code>x = [a, b, c]</code> the function would make <code>x = [c, b, a]</code>.</p>

<p>The problem is, I'm not allowed to use any built-in functions, and it has got me stuck. My initial thought was the following loop inside a function:</p>

<pre><code>for revert in range(1, len(x) + 1):
    y.append(x[-revert])
</code></pre>

<p>And it works. But the problem is I'm using <code>len(x)</code>, which I believe is a built-in function, correct? </p>

<p>So I searched around and have made the following very simple code:</p>

<pre><code>y = x[::-1]
</code></pre>

<p>Which does exactly what I wanted, but it just seems almost too simple/easy and I'm not sure whether <code>"::"</code> counts as a function. </p>

<p>So I was wondering if anyone had any hints/ideas how to manually design said function? It just seems really hard when you can't use any built-in functions and it has me stuck for quite some time now.</p>

<p>Another way ( just for completeness :) )</p>

<pre><code>def another_reverse(lst):
    new_lst = lst.copy() # make a copy if you don't want to ruin lst...
    new_lst.reverse() # notice! this will reverse it in place
    return new_lst
</code></pre>

python list python-3.x