Thanks for that!  Only a little thing, but I was getting very
confused.

-A.

On Jun 9, 12:01 am, Jason Bandlow <jband...@gmail.com> wrote:
> Alasdair wrote:
> > This is more of a python question than a Sage question, but
> > anyway...I'm trying to iterate over a list, producing a sequence of
> > new lists, each of which is obtained from the original list by
> > deleting one object.  I've tried:
>
> > for x in lst:
> >    lstc=copy(lst)
> >    print lstc.remove(x)
>
> > But this doesn't work - can anybody tell me what I'm doing wrong, and
> > what I should be doing?  I can get the effect I want by iterating over
> > the indices of the list, but I'd like to know why this little snippet
> > of code doesn't work.
>
> The problem is that
>
>     lstc.remove(x)
>
> modifies lstc in place and doesn't return anything.  So you aren't
> printing anything.  The following should do what you want:
>
> for x in lst:
>     lstc = copy(lst)
>     lstc.remove(x)
>     print lstc
>
> HTH,
> Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to