1

I am working on Python slicing, and I got confussed when the elemnts showed up in a undesired pattern

a = [1,2,3,4,5,6,78,]
a[2:1] = [7,9]

I tried to enter 7,9 into a existing list, I am getting below output

[1, 2, 7, 9, 3, 4, 5, 6, 78]

My point is with the positive slicing, if we are trying to access the elements in a reverse manner, it gives empty list.

  • So, how even this is adding elements to the list?
  • Even if its adding then how come 9 is placed after 7 in the list?

I hope my question makes sense.

Please suggest. Thank you.

user3521180
  • 1,044
  • 2
  • 20
  • 45

0 Answers0