From 2f9dd01f8c6380553184798805be756b7140f868 Mon Sep 17 00:00:00 2001 From: Patrick Cullinane Date: Wed, 24 Nov 2021 10:19:13 -0500 Subject: [PATCH] switch if statement order moving the if statement ahead of the for-loop would prevent the loop from checking the class attribute multiple times --- ch09-objects/e40_limited_size_bowl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch09-objects/e40_limited_size_bowl.py b/ch09-objects/e40_limited_size_bowl.py index a9a782a..9a5520c 100755 --- a/ch09-objects/e40_limited_size_bowl.py +++ b/ch09-objects/e40_limited_size_bowl.py @@ -30,8 +30,8 @@ def __init__(self): def add_scoops(self, *new_scoops): """Add one or more scoops to the bowl""" - for one_scoop in new_scoops: - if len(self.scoops) < Bowl.max_scoops: + if len(self.scoops) < Bowl.max_scoops: + for one_scoop in new_scoops: self.scoops.append(one_scoop) def __repr__(self):