[Tutor] insering into lists through slices

venkata subramanian venkatasubramanian at gmail.com
Fri Jun 3 19:12:51 CEST 2005

  I am a newbie to Python (that's very guessable).
  I simply fail to understand the semantics of the following piece of code.
  #assuming ls=[1,2,3,4]
 #then ls becomes
 >>> ls
[1, 5, 6, 2, 3, 4]

 i would be happy to know how it works.

 Basically, ls[1:1] returns an empty list and assigning [5,6] to it,
actually inserts the elements... but how?

More information about the Tutor mailing list