Python: Tuples versus Lists - what's the difference?
03 Sep 2022FixingChickentech
The key difference between a tuple and a list in python is that tuples are immutable objects whereas lists are not. That means that tuples cannot be changed in any way after their initialization.
So when we list of elements to be immutable, we can use a tuple. This will ensure the logical integrity of functions when needed. If we want to be able to alter the list after initialization, we can use the list object.
One interesting side note is that because lists are mutable, they cannot be used as dictionary keys (which need to be immutable). Tuples, however, can be used as dictionary keys.