Difference Between '+' and 'append' in Python (original) (raw)

Last Updated : 04 Jan, 2025

+ Operator creates a new sequence by concatenating two existing sequences and .append() method (available for lists) modifies the existing list in place by adding one item at the end. In this article we are going to compare ‘+’ operator and append in Python.

+ Operator in Python

+ operator is typically used for concatenation of sequences (strings, lists or tuples). When we use + between two sequences, Python creates a new sequence that contains the elements of both. For lists, using + does not modify the original lists. Instead, it returns a new list that is the result of the concatenation.

**Example:

Python `

s1 = "Hello" s2 = "World" res = s1 + " " + s2 print(res)

`

**Output:

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

Time Complexity of using + operator

**append method in python

append() method is specific to lists (and some other data structures like deque in the collections module, but most commonly used with lists). append() adds a single element to the end of the existing list. append() modifies the original list in place. It does not create a new list.

**Example:

Python `

n = [1, 2, 3] n.append([4, 5]) print(n)

`

**Output:

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

Time Complexity of using append method

Graphical comparison between ‘+’ and ‘append’

difference-between-append-and-plus-python

Comparison Between + operator and append method

Criteria + Operator .append() Method
Definition Concatenates two sequences and returns a new sequence. Adds a single element to the end of an existing list in place.
Data Types Works with sequences such as strings, lists, and tuples. Works only with lists (and similar data structures like deque).
Mutability Does not modify the original objects. Creates a new one. Modifies the original list in place.
Example list1 + list2 creates a new list. list.append(item) changes the existing list.
Resulting Object New object returned, original sequences remain unchanged. No new list is created, the original list is modified.
Time Complexity O(n + m) (copies elements from both lists). Amortized O(1) per append.
Typical Use Case Concatenate two sequences to produce a new one. Add a single element at a time to an existing list.