We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 65ba1b5 commit f242961Copy full SHA for f242961
1 file changed
barcode/ean.py
@@ -212,18 +212,19 @@ class EuropeanArticleNumber14(EuropeanArticleNumber13):
212
name = "EAN-14"
213
digits = 13
214
215
- def calculate_checksum(self):
+ def calculate_checksum(self) -> int:
216
"""Calculates the checksum for EAN13-Code.
217
218
- :returns: The checksum for `self.ean`.
219
- :rtype: Integer
+ :returns: The checksum for ``self.ean``.
220
"""
221
222
def sum_(x, y):
223
return int(x) + int(y)
224
225
- evensum = reduce(sum_, self.ean[::2])
226
- oddsum = reduce(sum_, self.ean[1::2])
+ ean_without_checksum = self.ean[: self.digits]
+
+ evensum = reduce(sum_, ean_without_checksum[::2])
227
+ oddsum = reduce(sum_, ean_without_checksum[1::2])
228
return (10 - (((evensum * 3) + oddsum) % 10)) % 10
229
230
0 commit comments