Re: [Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Ricardo Aráoz
Varsha Purohit wrote: > Thanks Eric and Alan i did that with while loop. I donno i was getting > an error while using a for loop for subindexing. Here is what i did > > i=0 > selectCols=0 > arr2=[] > while i selectCols=grid[i][colID] > i+=1 > arr2.append(selectCols) > > print "col"

Re: [Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Varsha Purohit
Thanks Eric and Alan i did that with while loop. I donno i was getting an error while using a for loop for subindexing. Here is what i did i=0 selectCols=0 arr2=[] while icolID is the value of the requested column to print. which remains the same throughout the iteration of while. On 9/2/07, Ala

Re: [Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Alan Gauld
"Varsha Purohit" <[EMAIL PROTECTED]> wrote > grid = [[1,1,2,7,6,9],\ > [,9,1,1,1,9,1],\ > [8,1,2,0,0,4],\ > [1,4,1,1,8,5]] You don't need the '\' characters, the fact that the closing bracket has not been reached means Python will ignore the newline characters. > ho

Re: [Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Eric Abrahamsen
> > COL = 5 > [i[COL-1] for i in grid] Should have guessed... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Ricardo Aráoz
Varsha Purohit wrote: > > > Hello, > Suppose i have a 2D list(grid) like > > grid = [[1,1,2,7,6,9],\ > [,9,1,1,1,9,1],\ > [8,1,2,0,0,4],\ > [1,4,1,1,8,5]] > > how can i access to all the elements of the list from column no. 5. > > output should be like [6,9,0,

Re: [Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Eric Abrahamsen
> grid = [[1,1,2,7,6,9],\ > [,9,1,1,1,9,1],\ > [8,1,2,0,0,4],\ > [1,4,1,1,8,5]] > > how can i access to all the elements of the list from column no. 5. > > output should be like [6,9,0,8]... Your basic tool is sub-indexing: you can reach items in the sub-lists by us

[Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Varsha Purohit
Hello, Suppose i have a 2D list(grid) like grid = [[1,1,2,7,6,9],\ [,9,1,1,1,9,1],\ [8,1,2,0,0,4],\ [1,4,1,1,8,5]] how can i access to all the elements of the list from column no. 5. output should be like [6,9,0,8]... thanks,- Varsha Purohit, __

[Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Varsha Purohit
Hello, Suppose i have a 2D list(grid) like grid = [[1,1,2,7,6,9],\ [,9,1,1,1,9,1],\ [8,1,2,0,0,4],\ [1,4,1,1,8,5]] how can i access to all the elements of the list from column no. 5. output should be like [6,9,0,8]... thanks,- Varsha Purohit, __