Python_Institute
PCEP-30-02 · Question #324
What is the expected output of the following code? my_list = [[3-i for i in range(3)] for j in range(3)] result = 0 for i in range(3): result += my_list[i][i] print(result)
The correct answer is A. 6. See the full explanation below for the reasoning.
Question
What is the expected output of the following code?
my_list = [[3-i for i in range(3)] for j in range(3)]
result = 0
for i in range(3):
result += my_list[i][i]
print(result)
Options
- A6
- B4
- C7
- D2
How the community answered
(35 responses)- A74% (26)
- B14% (5)
- C3% (1)
- D9% (3)
Community Discussion
No community discussion yet for this question.