What will be the output of the following Python code?

ICSE Class 10 Robotics & AI PYQ · 2025 Paper · Section A

2(viii)1 Mark · 2025 · Section A · 2025 Paper

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]].

← Previous questionNext question →

Browse the free Robotics & AI sample bank