On Fri, Feb 13, 2009 at 11:01 AM, bob gailer wrote:
> Moos Heintzen wrote:
>
>> I guess I can't reference [0] on an empty list. (I come from a C
>> background.)
>>
> Can you have an empty array in C? If so, it does not have any elements, so
> you can't refer to element 0.
I think the OP was co
Moos Heintzen wrote:
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 "", line 1, in ?
IndexError: list assignment index out of range
>>> d
[[]]
What's wrong with that?
However:
>>> d[0].append(1)
"Moos Heintzen" wrote
>>> d = [[]]
>>> d[0][0]=1
IndexError: list assignment index out of range
>>> d[0].append(1)
>>> d
[[1]]
I guess I can't reference [0] on an empty list.
Thats right. You can't assign a value to a position in
a list that hasn't been created yet. It has nothing to
do w
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 "", 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