[Tutor] Newbie: Sorting lists of lists

2008-06-18 Thread Keith Troell
Let's say I have a list of lists l == [[1, 2, 3], [2, 3, 1], [3, 2, 1], [1, 3, 2]] If I do a l.sort(), it sorts on the first element of each listed list: >>> l.sort() >>> l [[1, 2, 3], [1, 3, 2], [2, 3, 1], [3, 2, 1]] How can I sort on the second or third elements of the listed lists? Keith

Re: [Tutor] AttributeError: 'list' object has no attribute 'copy'

2006-11-27 Thread Keith Troell
On Nov 27, 2006, at 1:55 PM, Kent Johnson wrote: > Keith Troell wrote: >> I'm a rank beginner. I am running Python 2.3.5 on the Terminal of >> Mac OSX. >> The Tutorial (5.1) mentions list.copy as a list method. When I run > > Are you sure? I don't see

[Tutor] AttributeError: 'list' object has no attribute 'copy'

2006-11-27 Thread Keith Troell
I'm a rank beginner. I am running Python 2.3.5 on the Terminal of Mac OSX. The Tutorial (5.1) mentions list.copy as a list method. When I run scores = [1, 2, 3] copy = scores.copy () I get: AttributeError: 'list' object has no attribute 'copy' However, I am able to use .copy for dictionaries