I’ve seen there are actually two (maybe more) ways to concatenate lists in Python:

One way is to use the extend() method:

a = [1, 2]
b = [2, 3]
b.extend(a)

the other to use the plus (+) operator:

b += a

Now I wonder: which of those two options is the ‘pythonic’ way to do list concatenation and is there a difference between the two? (I’ve looked up the official Python tutorial but couldn’t find anything anything about this topic).

11 Answers
11

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *