Find the output of the following program:
Python3
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
Please comment below if you find anything wrong in the above post
Article Tags :
Recommended Articles