Meaning
Creates a new list containing all elements of the first list followed by all elements of the second list. The original lists remain unchanged.
Primary Function
List concatenation
Communicative Purpose
Combine two sequences into a single list.
Pattern
list_a + list_b
Core Structure
... + ...
Função primária
List concatenation
Propósito comunicativo
Combine two sequences into a single list.
Situações de gatilho
Merging results from two operations, combining user inputs, building a dataset from multiple sources.
Contextos
Data processing scripts, algorithms, any Python code that works with collections.
Padrão
list_a + list_b
Estrutura central
... + ...
Slots de substituição
list_a: list, list_b: list
Colocados típicos
- list literals
- the += operator
- list.extend() method
Substituições comuns
- list_a.extend(list_b)
- itertools.chain(list_a
- list_b)
- [*list_a
- *list_b]
Erros comuns
Assuming the operation modifies the original lists; using + on incompatible types; forgetting that it creates a new copy and may be inefficient for large lists.
Similar / contraste
list.extend() modifies the left list in place; + returns a new list; * repeats a list.
Interferências
Coming from languages where + only concatenates strings, may overlook its use for lists; from languages where + is strictly arithmetic.
Família do chunk
- list concatenation
- list repetition
- list slicing
Nuance
Works for any types that implement my_list + other_listaddmy_list + other_list; result type follows the left operand; for lists, returns a new list with O(len(list_a)+len(list_b)) time due to copying.
Efeito pragmático
Provides a clear, readable way to join lists without explicit loops.
Dica de memória
Think of the plus sign as stacking two lists on top of each other.
Nota
Creates a new list containing elements of both lists; original lists remain unchanged.
Upgrade path
Use itertools.chain for lazy iteration or [*a, *b] for unpacking syntax.
Log in to save chunks.