Merge pull request #8 from ethanrusz/use-none

Return None instead of empty list
This commit is contained in:
Em (Ethan) Ruszanowski 2024-02-16 16:11:47 -06:00 committed by GitHub
commit 8c992591a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

9
app.py
View file

@ -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. :param remaining_power: The remaining power in the current location.
:return: A list of all creatures that may still spawn. :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] [creature.name for creature in creatures if creature.power <= remaining_power]
) )
if spawnable != []:
return spawnable
else:
return None
def main(): def main():