What is the difference between working of append and + operator in a list in Python?

In this article, we will see the differences between two common ways of adding elements to lists in Python: the append method and the "+" operator.

  • The append() method is used to add elements to the list by modifying the original list in place.

  • The '+' operator is used to create a new list by concatenating existing lists.

Behaviour of "+" Operator with Python Lists

Python uses the '+' operator to create a new list by combining existing lists. When the '+' symbol is used, a new list is created with all elements from both lists, while the original lists remain unchanged.

Example

In this example, we will see the usage of the + operator to add elements to a list in Python −

numbers = []
n = 10
for i in range(n):
    numbers = numbers + [i]
print(numbers)

The output of the above code is −

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Time Complexity of Adding Elements Using the + Operator

When using the '+' operator in a loop, each iteration creates a new list and copies all existing elements. For the first iteration, 0 elements are copied. For the second, 1 element is copied. For the third, 2 elements are copied, and so on.

The total number of copy operations is 0 + 1 + 2 + ... + (n-1) = n(n-1)/2, which gives us a time complexity of O(n²).

Behaviour of append() Method with Lists

The append() method adds a single element to the end of an existing list, modifying the original list in place. This is much more efficient than creating new lists repeatedly.

Example

This example explains how to use the append() method −

numbers = []
n = 10
for i in range(n):
    numbers.append(i)
print(numbers)

The output of the above code is −

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Adding one element to an existing list using append() is an O(1) operation. Therefore, the total complexity of appending n elements is O(n).

Key Differences Between append() and "+" Operator

The '+' operator creates a new list when combining lists, leaving the original objects unchanged. The append() method modifies the original list in place. Additionally, append() adds the entire object as a single element, while '+' concatenates individual elements.

Example

The following example demonstrates the difference between the + operator and the append method −

list1 = [1, 2, 3]
list2 = ['a', 'b']
list3 = list1 + list2
print("Using + operator:")
print(list3)

list1.append(list2)
print("Using append method:")
print(list1)

The output of the above code is −

Using + operator:
[1, 2, 3, 'a', 'b']
Using append method:
[1, 2, 3, ['a', 'b']]

Comparison Summary

Aspect append() Method + Operator
Modifies Original Yes No
Creates New List No Yes
Time Complexity (n operations) O(n) O(n²)
Memory Usage Efficient Higher
Adds List as Single element Individual elements

Conclusion

Use append() for efficient single-element addition to lists. Use the '+' operator when you need to create new lists without modifying the originals. For performance-critical applications, append() is significantly faster due to its O(n) complexity versus O(n²) for repeated '+' operations.

Updated on: 2026-03-24T19:06:29+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements