A

Admin • 833.24K Points
Coach

Q. What is the output of the following code?

Code:
x = [1, 2, 3]
print(x * 2)
  • (A) [1, 2, 3, 1, 2, 3]
  • (B) [2, 4, 6]
  • (C) Error
  • (D) [1, 2, 3, 2]
  • Correct Answer - Option(A)
  • Views: 18
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

Multiplying a list replicates its elements. So [1,2,3] * 2 creates [1,2,3,1,2,3].

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.