Beginner question: difference between lists and tuples

Jim jhefferon at
Wed Mar 14 20:55:46 CET 2007

On Mar 14, 3:46 pm, "KDawg44" <KDaw... at> wrote:
> I am trying to learn python.  I am working through a tutorial on
>  I am trying to figure out how lists are different than
> tuples other than changing values at specific indices.
You can change lists but not tuples.  That has some advantages, as
when you append to a list.  But it has some disadvantages, as here
where I can't use a list as the key in a hash.

>>> d={[1,2]:'a'}
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: list objects are unhashable
>>> d={(1,2):'a'}


More information about the Python-list mailing list