Slicing and Dicing

(, en)

Als Referenz für mich.

(all)                            a[:]     -> ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
(first)                          a[:1]    -> ['a']
(first 6)                        a[:6]    -> ['a', 'b', 'c', 'd', 'e', 'f']
(last)                           a[-1:]   ->                                                   ['k']
(last 3)                         a[-3:]   ->                                         ['i', 'j', 'k']
(skip last)                      a[:-1]   -> ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
(skip last 3)                    a[:-3]   -> ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
(skip first 7)                   a[7:]    ->                                    ['h', 'i', 'j', 'k']
(4th till 8th)                   a[3:8]   ->                ['d', 'e', 'f', 'g', 'h']
(4th till 2nd last)              a[3:-1]  ->                ['d', 'e', 'f', 'g', 'h', 'i', 'j']
(4th last till 2nd last)         a[-3:-1] ->                                         ['i', 'j']
(reverse list)                   a[::-1]  -> ['k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']
(every 2nd item)                 a[::2]   -> ['a', 'c', 'e', 'g', 'i', 'k'] 
(every 2nd item, last to first)  a[::-2]  -> ['k', 'i', 'g', 'e', 'c', 'a']