python array inclusive slice index
<p>I wish to write a for loop that prints the tail of an array, <strong>including the whole array</strong> (denoted by i==0) Is this task possible without a branching logic, ie a <code>if i==0</code> statement inside the loop?</p>

<p>This would be possible if there is a syntax for slicing with inclusive end index. </p>

<pre><code>arr=[0,1,2,3,4,5]
for i in range(0,3):
    print arr[:-i]
</code></pre>

<p>output: </p>

<pre><code>[]
[0, 1, 2, 3, 4]
[0, 1, 2, 3]
</code></pre>

<p>wanted output: </p>

<pre><code>[0, 1, 2, 3, 4, 5]
[0, 1, 2, 3, 4]
[0, 1, 2, 3]
</code></pre>

<p>You can use <code>None</code>:</p>

<pre><code>arr=[0,1,2,3,4,5]
for i in range(0,3):
    print arr[:-i or None]
</code></pre>

python arrays numpy