A

Admin • 831.35K Points
Coach

Q. What will be the output of this code?

Code:
a = [1, 2, 3]
a[1:2] = [7, 8]
print(a)
  • (A) [1, 7, 8, 3]
  • (B) [1, 2, 3]
  • (C) [1, 7, 2, 3]
  • (D) [1, 8, 3]
  • Correct Answer - Option(A)
  • Views: 12
  • Filed under category Python
  • Hashtags:

Explanation by: Admin
Slicing assignment replaces the element at index 1 with two elements.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.