Lists: Constructing Lists
Concatenation
Syntax: list1 + list2
E.g.
>>> l1 = [1, 2]
>>> l1 + [3, 4, 5]
[1, 2, 3, 4, 5]
Repetition
Syntax: list * integer
E.g.
>>> [1, 2] * 5
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
Previous slide
Next slide
Back to first slide
View graphic version