At 11:01 PM 6/29/2008, wesley chun wrote:
> > e.g. can you predict the result of the following operations without trying it?
> >
> > a = [1, 2, 3, 4]
> > a[1:3] = [7, 8]
> > print a
>
>  [1, 7, 8, 4]   Whew!
>  (I really wasn't positive that it shouldn't be [1, [7, 8], 4] !)

good job dick! of course, you *know* i'm going to ask this...
how *do* you get it to be [1, [7, 8], 4] given the original 'a'?  :-)

I had to look at section 5.1 in the Python tutorial, for insert() and remove(), but didn't try them out. How about

a = [1,2,3,4]
a.remove(2)
a.remove(3)
a.insert(1,[7,8])

Next one?

Dick

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to