Step-by-step Explanation
1. list(range(10))
Creates a list of numbers from 0 to 9:
2. a[2:8:3]
This is list slicing, with the format:
start = 2 → Start from index 2 → element 2
stop = 8 → Go up to (but not including) index 8
step = 3 → Take every 3rd element
Indices from 2 to 7 are:
If we take every 3rd element starting from index 2:
-
First: index 2 → 2
-
Then: index 2 + 3 = 5 → 5
-
Next would be 5 + 3 = 8, which is excluded (stop is 8)
✅ Final Output:


0 Comments:
Post a Comment