Slicing provides a more
advanced way of retrieving values from a list. Basic list slicing involves
indexing a list with two colon-separated integers. This returns a new list
containing all the values in the old list between the indices.
The best way to learn new things is to take a practical approach of the things you want to learn. Here is a fragment of code that demonstrates the use of the Slicing statement in Python:
The best way to learn new things is to take a practical approach of the things you want to learn. Here is a fragment of code that demonstrates the use of the Slicing statement in Python:
Æ’ python command
cars = ('Tesla', 'Porsche', 'Ford',
'BMW', 'Audi')
print(cars[0])
print(cars[-5:-2])
print(cars[1:-1])
√ output
Tesla
('Tesla', 'Porsche', 'Ford')
('Porsche', 'Ford', 'BMW')
Sign up here with your email

ConversionConversion EmoticonEmoticon