why L[3:1]=['?'] become L.insert(3,'?')

sd44 sd44sd44 at yeah.net
Mon Oct 4 10:26:44 EDT 2010


In <learning python>
part III
how does Python handle it if you try to extract a sequence in reverse,
with the lower bound greater than the higher bound (e.g., L[3:1])? Hint:
try
assigning to this slice (L[3:1]=['?']), and see where the value is put.


>>> L=[1,2,3,4]

>>> L[3:1]
[]
>>> print L
[1, 2, 3, 4]
>>> L[3:1]=['?']
>>> print L
[1, 2, 3, '?', 4]




More information about the Python-list mailing list