I wish to write a for loop that prints the tail of an array, including the whole array (denoted by i==0) Is this task possible without a branching logic, ie a if i==0 statement inside the loop?
This would be possible if there is a syntax for slicing with inclusive end index.
arr=[0,1,2,3,4,5]
for i in range(0,3):
print arr[:-i]
output:
[]
[0, 1, 2, 3, 4]
[0, 1, 2, 3]
wanted output:
[0, 1, 2, 3, 4, 5]
[0, 1, 2, 3, 4]
[0, 1, 2, 3]