Post

Answer: A) [2, 3]
Negative indices count from the end:
1 2 3 4
-4 -3 -2 -1
nums[-3:-1]:
› Start: -3 = 2
› Stop: -1 = 4 (exclusive!)
› Takes: -3(2), -2(3)
› Result: [2, 3]
For beginners: Stop index is always exclusive. -1 is the last item but not included! To include the last element omit the index entirely nums[-3:]
English

@Python_Dv The output is A [2, 3].
The operation uses negative slicing to extract a specific portion of the list, exclusive of the stop index.
Explanation
List Definition: nums is a list containing [1, 2, 3, 4].
Negative Indexing: In Python, negative indices count from the
English

@Python_Dv Output:A) [2, 3].
Because:
-3 points to 2
-1 points to 4, but slice end is exclusive, so it stops before 4
So nums[-3:-1] → [2, 3].
English

@Python_Dv Definitely A! Slicing backwards is just a clever way to keep us on our toes.
English

@Python_Dv A. [2, 3]
Negative indexes count from the end. -3 start at 2, -1 stops before 4. Slicing includes the start and excludes the end.
English

@Python_Dv Negative indices count from the end:
Index: 0 1 2 3
Value: 1 2 3 4
Neg: -4 -3 -2 -1
Slice num[-3:-1]:
Start at index -3 → value 2
Stop at index -1 (not included) → value 4
So it includes elements at indices -3 and -2.
Final result: [2, 3]
English

@Python_Dv A) [2, 3]
nums[-3:-1] slices from index 1 to 3 (end excluded).
English














