On Tue, 23 Aug 2005, Terry Carroll wrote to Jonas: > I don't know if you're in a position to rely on the sortedness of the > input data, but even if not, this works: > > >>> l=[24, 24, 15, 16, 16, 15, 24] > >>> l=sorted(list(set(l)), reverse=True) > >>> l > [24, 16, 15]
Sorry, I missed you were on 2.3.x, and I think sorted() is new with 2.4. You'd instead have to do the sort in a separate step: >>> l=[24, 24, 15, 16, 16, 15, 24] >>> l=list(set(l)) >>> l.sort(reverse=True) >>> l [24, 16, 15] _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
