adplus-dvertising
frame-decoration

Question

What is the output of the code shown below?
l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]]
[[row[i] for row in l] for i in range(3)]

a.

Error

b.

[[1, 4, 7], [2, 5, 8], [3, 6, 9]]

c.

1 4 7
2 5 8
3 6 9

d.

(1 4 7)
(2 5 8)
(3 6 9)

Posted under Lists in Python Python

Answer: (b).[[1, 4, 7], [2, 5, 8], [3, 6, 9]]

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the code shown below?