> But as soon as I introduce the [0], in an attempt to access the first
> element of each sublist, I get the first sublist in its entirety:
>
>>>> aList[:][0]
> [1, 1, 1]


aList[:] is the shorthand way of taking a copy of aList thus
aList[:][0]

is the same as saying aList[0] except you get a new item.
Thus you could change the content of this version of [1,1,1] 
without affecting the original. Handy, but not what you want.

I don't know any easy way of getting the first items except maybe 
a list comprehension:

[lst[0] for lst in aList]

You could turn that into a parameterised function

def getRow(n):
   return [lst[n] for lst in aList]

Does that help?

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to