Given two lists:
x = [1,2,3] y = [4,5,6]
What is the syntax to:
x
y
[1, 2, 3, [4, 5, 6]]
[1, 2, 3, 4, 5, 6]
Do you mean append?
append
>>> x = [1,2,3] >>> y = [4,5,6] >>> x.append(y) >>> x [1, 2, 3, [4, 5, 6]]
Or merge?
>>> x = [1,2,3] >>> y = [4,5,6] >>> x + y [1, 2, 3, 4, 5, 6] >>> x.extend(y) >>> x [1, 2, 3, 4, 5, 6]
1.4m articles
1.4m replys
5 comments
57.0k users