Slicing
>>> a=[[1,2,3],[4,5,6],[7,8,9]] >>> a[0:2][0:2] # this is wrong [[1, 2, 3], [4, 5, 6]] >>> [a[i][0:2] for i in range(0,2)] # this is right [[1, 2], [4, 5]]
Last updated 4 years ago