Why the first output is including the first element (is seems to me like good behavior, because it starts with 0
index (that is that first element) and then increment with len(a)-1
(last element)).
Problem is that the second example (if it always starts with zero index and then increment) should be something like [1, 5, 4, 3, 2]
, or?
Output 1: [1, 5]
Output 2: [5, 4, 3, 2, 1]
a = [1, 2, 3, 4, 5]
print(a[::len(a)-1])
print(a[::-1])