Separate list into two equal parts with slices
<p>I need to write a function that splits any list into two equal parts. If length of list is even, I want just split it it two parts, and if length of the list is odd, I want to ignore central element.</p>

<pre><code>So [1,2,3,4,5,6] =&gt; [1,2,3] and [4,5,6]
and [1,2,3,4,5] =&gt; [1,2] and [4,5]
</code></pre>

<p>I tried to do the following way:</p>

<pre><code>list = [1,100,50,-51,1,1]
s = len(list)/2
left = list[s+1:]
right = list[:s]
</code></pre>

<p>But this approach doesnt work both for even and odd lengths. 
Is there a way to use slices for this purpose or there is no way and it's better to use loops/iterations?</p>

<p><code>A = [1,2,3,4,5,6]
 B = A[:len(A)/2]
 C = A[len(A)/2:]</code></p>

<p>If you want a function:</p>

<p><code>def split_list(a_list):
     half = len(a_list)/2
     return a_list[:half], a_list[half:]
A = [1,2,3,4,5,6]
B, C = split_list(A)</code></p>

<p>If you don't care about the order...</p>

<p><code>def split(list):<br>
    return list[::2]
    return list[1::2]</code></p>

<p>list[::2] gets every second element in the list starting from the 0th element.
list[1::2] gets every second element in the list starting from the 1st element.</p>

python