Skip to content

Commit

Permalink
utils : calculate percentage wo failing when zero…
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Sep 26, 2023
1 parent c591813 commit 0a3cba6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lacommunaute/utils/math.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def percent(a, b):
if b == 0:
return 0
return round((a / b) * 100, 2)

0 comments on commit 0a3cba6

Please sign in to comment.