Catch potential division by zero

This commit is contained in:
Kumi 2020-12-30 12:07:40 +01:00
parent 59491b7486
commit 57a22816a2

View file

@ -53,7 +53,10 @@ def average_mood(context, start, end=None):
for status in status_list: for status in status_list:
moods.append(status.mood.value) moods.append(status.mood.value)
try:
average = sum(moods) / len(moods) average = sum(moods) / len(moods)
except ZeroDivisionError:
average = None
return average return average