Skip to content

Commit

Permalink
Prevent divide by zero error when self.ratings is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
Slushnas committed Jul 11, 2018
1 parent af213eb commit 17ba1b9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions TomeRater.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def add_rating(self, rating):
print("Invalid Rating")

def get_average_rating(self):
if len(self.ratings) == 0:
return None
sum = 0
for rating in self.ratings:
sum += rating
Expand Down

0 comments on commit 17ba1b9

Please sign in to comment.