GUIDE深度 · Deep dive
List and Dict Output: Slices, Comprehensions, get
For lists, check index and slice bounds: [1:4] takes 1, 2, 3; a negative step reverses. For dicts, check whether the key exists: d[k] raises if missing, d.get(k) returns None. For comprehensions, read the expression first, then the condition.
Slicing
[start:stop:step]; stop is excluded.
[::-1] reverses.
Dicts
keys()/values()/items() return views; list() converts them.
get(k, default) does not raise.
FAQ
Comprehension order?
for first, then if, then the expression.
Are dicts ordered?
Python 3.7+ preserves insertion order.