A tuple is a immutable heterogenous data structure while Lists are homogenous sequences. Tuples have structure. Lists have order.

For example say we wanted to save notes in a book on a specific page an line number. We could define that data structure as a tuple.

my_location = (42, 11)   # page number, line number

And then use this as a key in a Dictionary to store notes on locations. A List on the other hand could be used to store multiple locations. Naturally one might want to add and remove from the list. That’s why Lists are mutable and tuples are immutable.

https://stackoverflow.com/questions/626759/whats-the-difference-between-lists-and-tuples

Advertisements