CBSE Class 11 Informatics Practices
Question 44 of 80
Lists in Python — Question 7
Back to all questions[1, 2, 3, '4', '5']
3
[1]
[4, 5, 6]
In the above code, L1 is defined as [1, 2, 3] and L2 as [4, 5, 6]. The first print(L1 + list("45")) concatenates L1 with the list representation of the string "45", resulting in [1, 2, 3, '4', '5']. The next operation print(L1.pop()) removes and returns the last element of L1, which is 3, printing it. Then, L1.remove(2) removes the element 2 from L1, leaving [1]. Subsequently, L1.extend(L2) appends elements from L2 to L1, modifying it to [1, 4, 5, 6]. Lastly, print(L2) outputs [4, 5, 6], showing that L2 remains unchanged despite being extended into L1.