0

I have a list numbers = [1,2,3,4,5] where len(numbers) = 5. when I Slice it with numbers[1:3], I got [2, 3] with 2 elements. so far no issues.

Now if assign this with more than 2 elements, say numbers[1:3] = ['a','b','c','d] , & re-check the numbers, I was expecting to get back [1, 'a', 'b', 4, 5]. chopping of ['c', 'd']. But I got [1, 'a', 'b', 'c', 'd', 4, 5] with 7 elements.

what happened here? why the list got extended?

Tommy
  • 515
  • 4
  • 13

0 Answers0