Skip to content

Commit

Permalink
Merge pull request #87 from eklairs/develop
Browse files Browse the repository at this point in the history
fix: division by zero error when calculating accuracy (#86)
  • Loading branch information
kraanzu authored Apr 30, 2024
2 parents 760ce55 + 8253187 commit 12652e9
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 12652e9

Please sign in to comment.