2(viii)
What will be the output of the following Python code?
x = [1, 2, 3, 4] x.append([5, 6]) print(x)
Show SolutionHide Solution↓
[1, 2, 3, 4, [5, 6]]
The append() method adds the given element as a single item at the end of the list. Here, [5, 6] is a list, so it is added as a nested list, not as individual elements. Hence, the final list becomes [1, 2, 3, 4, [5, 6]].