[Tutor] Why does L[3:2] =['test'] differ from L[3]=['test']

Glen Wheeler wheelege@tsn.cc
Thu, 9 Nov 2000 19:25:54 +1100


The results differ so you can still reference the nested list, I believe.
In case it has more than one value.

Like if the list you were putting in was [1, 2, 3] then the resultant would
be [1, 2, 3, [1, 2, 3], 5] and then it would be significant.

Sorry I'm still new to this.  Hope I helped.

Glen.

----- Original Message ----- 
From: Mallett, Roger <rmallett@rational.com>
To: <tutor@python.org>
Sent: Thursday, November 09, 2000 6:56 PM
Subject: [Tutor] Why does L[3:2] =['test'] differ from L[3]=['test']


> If a list L=[1, 2, 3, 4, 5]
> 
> then L[3:2]=['test'] yields -> [1, 2, 3, 'test', 5]
> 
> however, L[3]=['test'] yields -> [1, 2, 3, ['test'], 5]
> 
> Why do the results differ?  (one inserts a string into the list, but the
> other inserts a list into the list.)
> 
> Roger Mallett
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor