469,332 Members | 7,055 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Beginner question: difference between lists and tuples

Hi,

I am trying to learn python. I am working through a tutorial on
python.org. I am trying to figure out how lists are different than
tuples other than changing values at specific indices. How are these
different from arrays in other languages such as php?

THanks.

Mar 14 '07 #1
2 1020
Jim
On Mar 14, 3:46 pm, "KDawg44" <KDaw...@gmail.comwrote:
I am trying to learn python. I am working through a tutorial on
python.org. 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'}
Jim
Mar 14 '07 #2
KDawg44 a écrit :
Hi,

I am trying to learn python. I am working through a tutorial on
python.org. I am trying to figure out how lists are different than
tuples other than changing values at specific indices.
http://www.python.org/doc/faq/genera...ist-data-types
Mar 14 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

105 posts views Thread by Christoph Zwerschke | last post: by
7 posts views Thread by daniel | last post: by
7 posts views Thread by Shafik | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.