'Calculate the check digit for ISBN-13.
See https://en.wikipedia.org/wiki/International_Standard_Book_Number
for calculation.'

def _check_digit(self):

    weights = ((1 if ((x % 2) == 0) else 3) for x in range(12))
    body = ''.join([self.ean, self.group, self.registrant, self.publication])
    remainder = (sum(((int(b) * w) for (b, w) in zip(body, weights))) % 10)
    diff = (10 - remainder)
    check_digit = (0 if (diff == 10) else diff)
    return str(check_digit)
