CiscoCisco
350-401 · Question #1178
350-401 Question #1178: Real Exam Question with Answer & Explanation
The correct answer is B: 8 7 6 5. The Python code iterates four times, printing elements from the list my_list using negative indexing to access elements from the end backward.
Submitted by manish99· Mar 6, 2026Automation
Question
Refer to the exhibit. What is output by this code?
Options
- A-1 -2 -3 -4
- B8 7 6 5
- C4 5 6 7
- D-4 -5 -6 -7
Explanation
The Python code iterates four times, printing elements from the list my_list using negative indexing to access elements from the end backward.
Common mistakes.
- A. The code retrieves positive integer values from the list, not negative ones, and accesses them from the end, not starting from -1.
- C. This output would occur if positive indexing were used or the list was traversed in a different order, which is not what
my_list[-(x+1)]achieves. - D. The elements in
my_listare positive numbers, and the negative indexing only dictates position, not the sign of the retrieved value.
Concept tested. Python list negative indexing and loops
Reference. https://docs.python.org/3/tutorial/introduction.html#lists
Topics
#Python scripting#Code interpretation#Control flow
Community Discussion
No community discussion yet for this question.