Python_Institute
PCEP-30-02 · Question #375
What is the output of the following code? ``python my_list = [3, 1, -1] my_list[-1] = my_list[-2] print(my_list) ``
The correct answer is C. [3, 1, 1]. See the full explanation below for the reasoning.
Question
What is the output of the following code?
my_list = [3, 1, -1]
my_list[-1] = my_list[-2]
print(my_list)
Options
- A[1, 1, 1]
- B[3, -1, 1]
- C[3, 1, 1]
- D[3, 1, -1]
How the community answered
(46 responses)- A2% (1)
- B7% (3)
- C76% (35)
- D15% (7)
Community Discussion
No community discussion yet for this question.