<html>
<body>
At 01:39 PM 6/30/2008, Dick Moores wrote:<br>
<blockquote type=cite class=cite cite="">At 11:01 PM 6/29/2008, wesley
chun wrote:<br>
<blockquote type=cite class=cite cite="">> > e.g. can you predict
the result of the following operations without trying it?<br>
> ><br>
> > a = [1, 2, 3, 4]<br>
> > a[1:3] = [7, 8]<br>
> > print a<br>
><br>
> [1, 7, 8, 4] Whew!<br>
> (I really wasn't positive that it shouldn't be [1, [7, 8], 4]
!)<br><br>
good job dick! of course, you *know* i'm going to ask this...<br>
how *do* you get it to be [1, [7, 8], 4] given the original 'a'?
:-)</blockquote><br>
I had to look at section 5.1 in the Python tutorial, for insert() and
remove(), but didn't try them out. How about<br><br>
<tt>a = [1,2,3,4]<br>
a.remove(2)<br>
a.remove(3)<br>
a.insert(1,[7,8])</tt></blockquote><br>
Hey!<br><br>
>>> a = [1,2,3,4]<br>
>>> a.remove(2)<br>
>>> a.remove(3)<br>
>>> a.insert(1,[7,8])<br>
>>> a<br>
[1, [7, 8], 4]<br>
>>> <br><br>
Show me a better way?<br><br>
Dick<br><br>
</body>
</html>