N
What is the difference between a list and a tuple in Python?
AI
Lists are mutable, tuples are immutable. Lists use square brackets, tuples use parentheses. Tuples are slightly faster and can be used as dictionary keys.
N
When would I pick one over the other?
AI
Use a list when the collection will change. Reach for a tuple when the collection is fixed and you want the immutability guarantee, or when you need to use it as a key.