From 1a95687e59b45b74f0eb33d00b2f9d39fc8ebe25 Mon Sep 17 00:00:00 2001 From: Ethan Ruszanowski Date: Fri, 16 Feb 2024 17:07:28 -0500 Subject: [PATCH] Return None instead of empty list --- app.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 5eb7511..d8c38fb 100644 --- a/app.py +++ b/app.py @@ -32,9 +32,16 @@ def find_spawnlist(remaining_power: int, creatures: list[Creature]) -> list[str] :param remaining_power: The remaining power in the current location. :return: A list of all creatures that may still spawn. """ - return sorted( + if remaining_power == 0: + return None + + spawnable = sorted( [creature.name for creature in creatures if creature.power <= remaining_power] ) + if spawnable != []: + return spawnable + else: + return None def main():