kenneth gonsalves <lawgon@...> writes:

> On Sat, 2011-12-31 at 10:36 +0000, Sameer wrote:
> > > >>> scores = [5,2,3]
> > > >>> sum(sorted(scores)[1:3])
> > > 8
> > 
> > sum(sorted(scores)[-2:])
> > 
> > seems like a more general solution. 
> 
> nice (but the same number of keystrokes )

:) I didn't even think about that. Actually, I was trying to figure out the
slice syntax (Python's has never been intuitive) and realised 1:3 is specific to
a 3-element list.




_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to