Lists: What will the output of the following program be?

Code:

L = [1, 2, 3, 4]
print(L * 2)
  • [2, 4, 6, 8]
  • [1, 2, 3, 4, 1, 2, 3, 4]
  • [[1, 2, 3, 4], [1, 2, 3, 4]]
  • Error

L * 2 simply replicates the elements of the list twice. The dimensions remain the same. Hence, the output that you get is [1, 2, 3, 4, 1, 2, 3, 4].

Comments