Report Bug

Qus

What will be the output of the following Python code?

lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print(lst)
Qus

निम्नलिखित Python कोड का आउटपुट क्या होगा?

lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print(lst)


A. [3, 7, 8, 6, 1, 2]
B. Syntax error
C. [3,[7,8],6,1,2]
D. [3,4,6,7,8]


Solution
A. [3, 7, 8, 6, 1, 2]



Explanation
In the piece of code, slice assignment has been implemented. The sliced list is replaced by the assigned elements in the list. Type in python shell to verify.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz