def checksum(sin):
    """
    Determine validity of a Canadian Social Insurance Number.
    Validation is performed using a modified Luhn Algorithm.  To check
    the Every second digit of the SIN is doubled and the result is
    summed.  If the result is a multiple of ten, the Social Insurance
    Number is considered valid.

    https://en.wikipedia.org/wiki/Social_Insurance_Number
    """

    # Remove spaces and create a list of digits.
    checksumCollection = list(sin.replace(' ', ''))
    checksumCollection = [int(i) for i in checksumCollection]

    # Discard the last digit, we will be calculating it later.
    checksumCollection[-1] = 0

    # Iterate over the provided SIN and double every second digit.
    # In the case that doubling that digit results in a two-digit
    # number, then add the two digits together and keep that sum.

    for i in range(1, len(checksumCollection), 2):
        result = checksumCollection[i] * 2
        if result < 10:
            checksumCollection[i] = result
        else:
            checksumCollection[i] = result - 10 + 1

    # The appropriate checksum digit is the value that, when summed
    # with the first eight values, results in a value divisible by 10

    check_digit = 10 - (sum(checksumCollection) % 10)
    check_digit = (0 if check_digit == 10 else check_digit)

    return check_digit
Determine validity of a Canadian Social Insurance Number.
    Validation is performed using a modified Luhn Algorithm.  To check
    the Every second digit of the SIN is doubled and the result is
    summed.  If the result is a multiple of ten, the Social Insurance
    Number is considered valid.

    https://en.wikipedia.org/wiki/Social_Insurance_Number