+ 2
While counting the index from right side in a list, should we start from 0 or -1 ?
[::-2] which value is the [-2]? 3rd from the right or 2nd from the right ? I lost a challenge because of it. And in other challenge lost same question with other logic..
2 ответов
+ 1
Right side starts with -1. It's an abbreviation of length-1 which you would write in other languages.
+ 1
Ah, okay, I see the issue now.
The third slot of a slice is 'step'.
The -2 has no direct relation to backwards indexing like array[-1].
-2 here just means that the slice makes downward jumps of 2.