Python Program to Slice Lists (Get all the Items Before a Specific Position)

bookmark

my_list = [1, 2, 3, 4, 5]

print(my_list[:2])

 

Output

[1, 2]