Saturday, March 24, 2018

Indexing, Slicing and Matrixes


Indexing, Slicing and Matrixes

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

Assuming the following input-

L=['C++'', 'Java', 'Python']

Python Expression
Results
Description
L[2]
‘Python’
Offsets start at zero
L[-2]
‘Java’
Negative: count from the right
L[1:]
[‘Java’, ‘Python’]
Slicing fetches sections






<<<Basic List Operations              Index