Lists and Tuples

sdd daniels at dsl-only.net
Sat Dec 6 00:10:39 EST 2003


Jeff Wagner wrote:
> I've spent most of the day playing around with lists and tuples to get a really good grasp on what
> you can do with them. I am still left with a question and that is, when should you choose a list or
> a tuple? I understand that a tuple is immutable and a list is mutable but there has to be more to it
> than just that.  Everything I tried with a list worked the same with a tuple. So, what's the
> difference and why choose one over the other?
> 
> Jeff
Here's the biggie:

association = {}
somevals = 1,2,6,'a'
association[somevals] = 13

vs.

association = {}
somevals = [1,2,6,'a']
association[somevals] = 13

-Scott David Daniels
Scott.Daniels at Acm.Org





More information about the Python-list mailing list