Python list
a =[0,1,2,3,4,5,6,7,8,9] b = a [i:j] means copy a [i] to a[j-1] to generate a new List b b = a[1:3] so the content of b is [1,2] When i defaults, the default is 0, that is, a[:3] is equivalent to a [0:3] When j defaults, it defaults to len(a), i.e. a [1:] is equivalent to a [1:10] When i and j are default, a [:] is equivalent to a complete copy of a b = a [i:j:s], i,j is the same as above, but s means step, default is 1. a[i:j:1] is equivalent to a [i:j] When s <0, i defaults to -1. j defaults to -len(a)-1 a[::-1] is the same thing as a [-1:-len(a)-1:-1], which is the same thing as going from the last element to the first element. The last element is -1 and the second last is -1+s = -2, so the first element 0 is -10. nums[1:][::-1] means reverse the list nums[1:], so we can get [9, 8, 7, 6, 5, 4, 3, 2, 1] get the element reversely through 'for' loop: for j in xrange(len(nums)-1, 0, -1):