CBSE Class 12 Computer Science
Question 57 of 68
Data Structures - I : Linear Lists — Question 13
Back to all questions[[9, 6], [4, 5, 10]]
b = [[9, 6], [4, 5], [7, 7]]— This line initializes a listbcontaining three sublists, each containing two elements.x = b[:2]— This line creates a new listxby slicing the listbfrom index 0 to index 1. So,xwill contain the first two sublists ofb. At this point,xwill be[[9, 6], [4, 5]].x[1].append(10)— This line accesses the second sublist ofx, which is[4, 5], and appends 10 at its end. Nowxbecomes[[9, 6], [4, 5, 10]]print(x)— This line prints the listx.