[Ilugc] [PYTHON] sum of best two scores of three
- From: lawgon@xxxxxxxxxxxxxxx (kenneth gonsalves)
- Date: Sat, 31 Dec 2011 16:40:48 +0530
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 ;-))
--
regards
Kenneth Gonsalves
Other related posts: