Hello

2009-07-09 Thread Tanmoy
Hi ...
I have been trying to set this 2-D array of this sort.

  0 10 20 ... 1000
  1 11 21...

   1000


Here is the code i tried ...

arr=[]
for i in range(0,1010,10):
arr.append([])
for j in range(0,1001,1):
  arr[i].append(i+j)

print arr

I am getting the following error
 list index out of range

Please let me know where am i getting wrong.

Sincerely
tank
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 70, Issue 123

2009-07-09 Thread Tanmoy
Hello ,
  When i==0 you append an empty list to arr, so arr[i] is arr[0]. No
problem.

When i==10 you append another empty list to arr, so arr[i] is arr[10].
Index error because there's no arr[10], only arr[0] and arr[1].


Thanks for your prompt reply...

How can i pass this problem


Sincerely
Tanmoy
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello

2009-07-09 Thread Tanmoy

 Hello ,
  When i==0 you append an empty list to arr, so arr[i] is arr[0]. No
 problem.

 When i==10 you append another empty list to arr, so arr[i] is arr[10].
 Index error because there's no arr[10], only arr[0] and arr[1].

 Thanks for your prompt reply...

 How can i pass this problem

  You could try appending to arr[-1] instead.

Better still:

   ...
   row = []
   for j in range(0,1001,1):
 row.append(i+j)
   arr.append(row)
   ...
I tried both the ways... the only thing is its not coming like 0 10
20...1000 . Its coming like 0,1,2,1000.Any answer to the
problem.
Thanks
Tanmoy Mukherjee
-- 
http://mail.python.org/mailman/listinfo/python-list