From de8a5ec8e220b5aa1fefcdc32e93033b01263e1d Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Tue, 13 Jan 2015 11:04:39 +0100 Subject: [PATCH] Use generator instead of list comprehension When calling sum(), there's no need to pre-evaluate its argument into a list, when a generator will do just fine. --- pf/yatzy/yatzy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pf/yatzy/yatzy.py b/pf/yatzy/yatzy.py index da73bcd..3b396e3 100644 --- a/pf/yatzy/yatzy.py +++ b/pf/yatzy/yatzy.py @@ -22,7 +22,7 @@ def score_ones(dice): def score_twos(dice): - return sum([d for d in dice if d == 2]) + return sum(d for d in dice if d == 2) def score_threes(dice):