Python - List Indexing, Slicing, and Matrixes

Introduction

Lists are sequences, indexing and slicing work the same way for lists as they do for strings.

The result of indexing a list is whatever type of object lives at the offset you specify.

Slicing a list always returns a new list:

Demo

L = ['test', 'Test', 'TEST!'] 
print( L[2] )                              # Offsets start at zero 
print( L[-2] )                             # Negative: count from the right 
print( L[1:] )                             # Slicing fetches sections
#   ww w  . jav a  2s  .c o  m

Result