Post

Python Developer
Python Developer@Python_Dv·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
23
4
101
13.6K
Sergei Kotov
Sergei Kotov@kotov_dev·
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
0
0
5
426
Earnest Codes
Earnest Codes@Earnesto037·
@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
1
0
5
824
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@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
0
0
1
863
Vu2day🆗
Vu2day🆗@vu2day·
@Python_Dv Definitely A! Slicing backwards is just a clever way to keep us on our toes.
English
0
0
0
675
Himal
Himal@himalbhattaraix·
@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
0
0
0
146
Ehshanulla
Ehshanulla@Ehshanulla·
@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
0
0
0
26
ANKIT 𓃱
ANKIT 𓃱@A9kitSingh·
@Python_Dv A) [2, 3] nums[-3:-1] slices from index 1 to 3 (end excluded).
English
0
0
0
489
Paylaş