From 1c0766e98529d2b923699226b68cfafa5988e72b Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Mon, 2 Jan 2023 10:11:20 -0600 Subject: [PATCH] hacky fix the indexerror --- creeper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/creeper.py b/creeper.py index 04155eb..c38e6c2 100755 --- a/creeper.py +++ b/creeper.py @@ -287,8 +287,12 @@ class Creeper(Game): for i, tree in enumerate(copy(self.trees)): if tree.health <= 0: self.inventory["log"] = self.inventory.get("log", 0) + 10 - del self.trees[i] - print(f"you have {self.inventory['log']} log") + try: + del self.trees[i] + except IndexError: + # get this one on the next pass + # killing two items in the same frame will error + ... def game(self): creeper = next(self.creepers)