[TriZPUG] filling lists

Chris Calloway cbc at unc.edu
Tue Apr 7 00:44:01 CEST 2009

On 4/6/2009 4:18 PM, Joseph Mack NA3T wrote:
> well dang. I didn't see that in the methods and functions for lists.

It's an operator. The subscription operator. Which applies to sequences.

On the left hand side of an assignment, it is only applicable to mutable 


You can use it on your two dimensional list like so:

 >>> twodlist = [[1,2,3],[3,4,5],[6,7,8]]
 >>> print twodlist[1][1]

Note, multidimensional lists need not be orthogonal. That is, the "rows" 
do not need to be the same length. Because the "outer" list is also 
heterogeneous. Python doesn't care that each item is even a list, much 
less how long of a list.

However, you are certainly free to make orthogonal multidimensional 
lists. Python doesn't care. It's flexible.


Chris Calloway
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599

More information about the TriZPUG mailing list