नीचे दिए गए कोड स्निपेट में ___ क्या होगा?
What will be the output of the following code snippet?
a=[1,2,3,4,5,6,7,8,9]
a[::2]=10,20,30,40,50,60
print(a)
A
ValueError: attempt to assign sequence of size 6 to extended slice of size 5
B
[10, 2, 20, 4, 30, 6, 40, 8, 50, 60]
C
[1, 2, 10, 20, 30, 40, 50, 60]
D
[1, 10, 3, 20, 5, 30, 7, 40, 9, 50, 60]
Explanation
You are trying to replace 5 elements (from indices 0, 2, 4, 6, 8) with 6 new values. This causes a mismatch in size, resulting in a ValueError.
So, the answer is (A) ValueError: attempt to assign sequence of size 6 to extended slice of size 5.
Correct Answer: A) ValueError: attempt to assign sequence of size 6 to extended slice of size 5