List Concatenation and ReplicationΒΆ

As with strings, we can use the operators + and * to concatenate and replicate lists.

  • When + appears between two lists, the expression will be evaluated as a new list that contains the elements from both lists. The elements in the list on the left of + will appear first, and the elements on the right will appear last.

  • When * appears between a list and an integer, the expression will be evaluated as a new list that consists of several copies of the original list concatenated together. The number of copies is set by the integer.

letter_list = ['A', 'B', 'C']
number_list = [1, 2, 3]

print(letter_list + number_list)
print(number_list * 4)
['A', 'B', 'C', 1, 2, 3]
[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]