Q Quốc Ân New member Sep 20, 2021 #1 What will be the output of the following Python code? Code: 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]
What will be the output of the following Python code? Code: 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]
S Stasenndb New member Sep 20, 2021 #2 Answer: a 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. Upvote 0 Downvote
Answer: a 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.