something go wrongly

levi nie levinie001 at gmail.com
Sat Jul 7 13:51:38 EDT 2012


Thanks,
Such methods return None to emphasize that they
do not create new lists.
i got it.
2012/7/8 Chris Rebert <clp2 at rebertia.com>

> On Sat, Jul 7, 2012 at 10:23 AM, levi nie <levinie001 at gmail.com> wrote:
> > my code:
> >
> > aList=[1,2,3,4,5,6,7,8,9,10]
> > xList=[1,2,3]
> > print "now aList is",aList.extend(xList)
> >
> > output:
> > now aList is None
> >
> > what i want is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]
>
> See http://stackoverflow.com/a/1682601
> list.extend(), list.append(), etc. operate in-place, mutating the
> existing list object. Such methods return None to emphasize that they
> do not create new lists.
>
> Regards,
> Chris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120708/953b8839/attachment.html>


More information about the Python-list mailing list