Possible Duplicate:
Python append() vs. + operator on lists, why do these give different results?
What is the actual difference between "+" and "append" for list manipulation in Python?
Possible Duplicate:
Python append() vs. + operator on lists, why do these give different results?
What is the actual difference between "+" and "append" for list manipulation in Python?
+
is a binary operator that produces a new list resulting from a concatenation of two operand lists.append
is an instance method that appends a single element to an existing list.P.S. Did you mean
extend
?Using
list.append
modifies the list in place - its result isNone
. Using + creates a new list.There are two major differences. The first is that
+
is closer in meaning toextend
than toappend
:The other, more prominent, difference is that the methods work in-place:
extend
is actually like+=
- in fact, it has exactly the same behavior as+=
except that it can accept any iterable, while+=
can only take another list.The
+
operation adds the array elements to the original array. Thearray.append
operation inserts the array (or any object) into the end of the original array.Take a look here: Python append() vs. + operator on lists, why do these give different results?