List Slicing Shorthand : List Sliced « List « Python






List Slicing Shorthand

List Slicing Shorthand
 

li = ['a', 'b', 'mpilgrim', 'z', 'example'] 
print li[:3]                                             

print li[3:]                                             

print li[:]                                             
           
         
  








Related examples in the same category

1.List slice assignment: delete and insertList slice assignment: delete and insert
2.List slicingList slicing
3.List: display a sliceList: display a slice
4.List indices start at 0, and lists can be sliced, concatenated:List indices start at 0, and lists can be sliced, concatenated:
5.Getting a List Subset: SlicingGetting a List Subset: Slicing
6.Slicing works similar to strings; use the square bracket slice operator ([ ] ) along with the index or indices.