[Tutor] append vs list addition
C Smith
illusiontechniques at gmail.com
Sun May 4 15:51:17 CEST 2014
Sorry.
I meant for example:
list1 = [1,2,3]
list2 = [3,4,5]
newList = list1 + list2
versus
for x in list2:
list1.append(x)
Which is the preferred way to add elements from one list to another?
On Sun, May 4, 2014 at 7:36 AM, Dave Angel <davea at davea.name> wrote:
> C Smith <illusiontechniques at gmail.com> Wrote in message:
>>
>>
> I had always assumed that append() was more efficient, but some recent discussions seem to point at that it is the same as append(). Which is preferable and why?
>
> Please be more explicit, preferably with example code.
> list.append and list.__add__ don't even do the same thing.
> Perhaps you mean list.extend
>
> I would also encourage you to properly use text mail to post, as
> there are a number of problems triggered by html mails as you're
> doing now. Most of them don't matter with your current message,
> however.
>
> --
> DaveA
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list