Skip to content

Commit 0607503

Browse files
committed
Fixed a bug in calculating checksum for EAN-8 barcodes.
1 parent 9c14b6b commit 0607503

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

barcode/ean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def calculate_checksum(self):
143143
sum_ = lambda x, y: int(x) + int(y)
144144
evensum = reduce(sum_, self.ean[::2])
145145
oddsum = reduce(sum_, self.ean[1::2])
146-
return 10 - ((evensum * 3 + oddsum) % 10)
146+
return (10 - ((evensum * 3 + oddsum) % 10)) % 10
147147

148148
def build(self):
149149
"""Builds the barcode pattern from `self.ean`.

0 commit comments

Comments
 (0)