Python-Quizzes | Python List Quiz | Question 16
Question 16: Find the output of the following program:
data = [2, 3, 9] temp = [[x for x in[data]] for x in range(3)] print (temp) |
(A) [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]
(B) [[2, 3, 9], [2, 3, 9], [2, 3, 9]]
(C) [[[2, 3, 9]], [[2, 3, 9]]]
(D) None of these
Answer: (A)
Explanation: [x for x in[data] returns a new list copying the values in the list data and the outer for statement prints the newly created list 3 times.
Quiz of this Question



