Python Program to Slice Lists (Get all the Items Before a Specific Position)
my_list = [1, 2, 3, 4, 5]
print(my_list[:2])
Output
[1, 2]
my_list = [1, 2, 3, 4, 5]
print(my_list[:2])
Output
[1, 2]