Question 7
Back to Exercise
The program should print the last three readings. Which statement correctly identifies the bug?
readings = [31, 29, 33, 35, 30, 28]
print(readings[-3:-1])
- A Negative indexes count from the start
- B The stop index -1 excludes the last item; write readings[-3:] Correct
- C Slices cannot use negative numbers
- D It should be readings[3:-1]
Correct Answer: Option B
A slice stops before its stop index; leave it out to go to the end.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!