nerdexam
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)
  • A
    2% (1)
  • B
    7% (3)
  • C
    76% (35)
  • D
    15% (7)

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice