Mega Code Archive

 
Categories / Python / List
 

List offset

L = ['spam', 'Spam', 'SPAM!'] print L[2]                               # offsets start at zero print L[-2]                              # negative: count from the right print L[1:]                              # slicing fetches sections