Python Lists, Tuples, Sets and Dictionaries Explained
Choose the right built-in collection for sequences, fixed records, unique values and lookups.
Lists
tasks = ["plan", "code", "test"]tasks.append("deploy")
tasks[0] = "review"
Lists are ordered and mutable.
Tuples
coordinates = (22.5726, 88.3639)latitude, longitude = coordinates
Tuples are useful for fixed groups of values.
Sets
roles = {"admin", "editor", "admin"}print(roles) # duplicates are removed
Sets are useful for uniqueness and membership checks.
Dictionaries
employee = {"name": "Riya", "team": "engineering"}employee["location"] = "Kolkata"
print(employee.get("team"))
Dictionaries store key-value pairs and are useful for records and lookups.
Quick guide
| Need | Choose |
| Ordered, mutable sequence | list |
| Fixed group of values | tuple |
| Unique values | set |
| Key-value lookup | dict |
Keep learning
Try the concepts in a small project and verify version-specific details with official documentation.
More Python resources