Lesson 6
Dealing with Sequences of Objects
Chapter 2: Lists
List slicing
Python also provides a convenient way to perform list slicing to slice out a subset of your list.
>>> students = ["Abraham", "Bella", "Connor", "Da-ming", "Enya"]
>>> print(students[1:4]) # ["Bella", "Connor", "Da-ming"]
The output list does NOT include the element specified in the end index. Personally, I find the easier way to think about slicing is to ‘slice’ up your list between the elements, like slicing a pizza! 🍕🍕🍕
Try the following questions. Again, don’t skip this! Some of the tips here might come useful, and some of them tricky!
❮
❯