Skip to main content

List Slicing

List slicing allows you to access a portion of a list by specifying a start index, end index, and optionally a step size.

myList.py
my_list = [1, 2, 3, 4, 5]
print(my_list[1:4])
Output
[2, 3, 4]