Skip to content

Commit

Permalink
fix: division by zero error when calculating accuracy (kraanzu#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
eklairs committed Apr 30, 2024
1 parent 760ce55 commit 8253187
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion smassh/src/stats_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ def raw_wpm(self) -> int:

@property
def accuracy(self) -> int:
accuracy = (self.correct / (self.correct + self.incorrect)) * 100
total_typed = self.correct + self.incorrect

if total_typed == 0:
return 0

accuracy = (self.correct / total_typed) * 100

return round(accuracy)

@property
Expand Down

0 comments on commit 8253187

Please sign in to comment.