Hi,
I was wondering why this happens. I was trying to create a list of lists.

>>> d = [[]]
>>> d[0][0]=1
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
IndexError: list assignment index out of range
>>> d
[[]]

What's wrong with that?

However:
>>> d[0].append(1)
>>> d
[[1]]

I guess I can't reference [0] on an empty list. (I come from a C background.)
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to