List indices start at 0, and lists can be sliced, concatenated: : List Sliced « List « Python






List indices start at 0, and lists can be sliced, concatenated:

List indices start at 0, and lists can be sliced, concatenated:
 


a = ['spam', 'eggs', 100, 1234]
print a[0]

print a[3]

print a[-2]

print a[1:-1]

print a[:2] + ['bacon', 2*2]

print 3*a[:3] + ['Boo!']



           
         
  








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.Getting a List Subset: SlicingGetting a List Subset: Slicing
5.Slicing works similar to strings; use the square bracket slice operator ([ ] ) along with the index or indices.
6.List Slicing ShorthandList Slicing Shorthand