python at mrabarnett.plus.com
Thu Jul 9 10:41:42 CEST 2009
T Hi ...
> I have been trying to set this 2-D array of this sort.
> 0 10 20 ........... 1000
> 1 11 21...............
> Here is the code i tried ...
> for i in range(0,1010,10):
> for j in range(0,1001,1):
> print arr
> I am getting the following error
> list index out of range
> Please let me know where am i getting wrong.
The value of 'i' goes 0, 10, ..., etc.
When i==0 you append an empty list to arr, so arr[i] is arr. No
When i==10 you append another empty list to arr, so arr[i] is arr.
Index error because there's no arr, only arr and arr.
More information about the Python-list