Overview:
- Slicing operations on a list using a begin index and end index returns list slices containing shallow copies of list elements.
Example:
# A list of things as seen from the window print("List elements:"); # Take few elements from the middle # Take few elements from the last # Take few elements from the beginning # Extract few elements from the beginning |
Output:
List elements: ['sky', 'cloud', 'rain', 'rainbow', 'sun', 'aircraft', 'trees'] ['rain', 'rainbow'] ['aircraft', 'trees'] ['sky', 'cloud'] ['cloud', 'rain', 'rainbow'] |