Lists and indexing
Lists are ordered mutable sequences that can contain repeated values. Index zero selects the first item, negative indexes count from the end, and slicing creates selected subsequences. append mutates a list and returns None rather than the new list. An index outside the current length raises IndexError. services=["api","worker"]; services.append("api"); print(services[0],services[-1],len(services)) prints api api 3 because duplicates are preserved and append changed the existing list. Sequence semantics matter when order and repeated observations are meaningful, such as request events or deployment steps, and distinguish mutable updates from methods that return new collections to a caller explicitly. Assigning services=services.append("db") replaces your variable with None; call append separately and inspect the original list instead of assuming every mutation returns the updated object for further use.
services=["api","worker"]; services.append("api"); print(services[0],services[-1],len(services)) prints api api 3 because duplicates are preserved and append changed the existing list.Sequence semantics matter when order and repeated observations are meaningful, such as request events or deployment steps, and distinguish mutable updates from methods that return new collections to a caller explicitly.
Assigning services=services.append("db") replaces your variable with None; call append separately and inspect the original list instead of assuming every mutation returns the updated object for further use.