[Tutor] s[len(s):len(s)] = [x] ??
Dick Moores
rdm at rcblue.com
Mon Jun 30 04:12:07 CEST 2008
At 03:39 PM 6/29/2008, John Fouhy wrote:
>On 28/06/2008, Dick Moores <rdm at rcblue.com> wrote:
> > I'm very familiar with appending x to a list, s, using
> s.append(x), however,
> > I've never understood what the docs mean by
> >
> > s.append(x) same as s[len(s):len(s)] = [x]
>
>In addition to Douglas's comment, do you understand how assignment
>with slices works?
>
>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
I can't make much more of a fool of myself than I already have on
this list, so here goes: [1, 7, 8, 4]
But it's tough to hit that Send button..
Dick
More information about the Tutor
mailing list