Lists
Python List Interview Questions
List questions are the everyday work of Python: building a list, filtering it, combining two of them, usually in a single line.
What list questions ask you to do
Across the questions here, these are the shapes that come up:
- Filter and transform in one step
- Flatten a nested structure
- Combine two lists with a rule about duplicates
- Split a list into fixed-size batches
- Return a new list without changing the original
Common mistakes with lists
Assigning a list to a second name does not copy it. Both names point at the same list, so adding to one changes the other, and the problem usually shows up a long way from the line that caused it. Copying it explicitly is the fix.