def mod10(list):
    
    """Implements the Luhn Algorithm (a.k.a. mod10), which 
    is a checksum formula to validade a variety of 
    identification numbers, such as credit card numbers.
    
    Requires a list of integers with the numbers to be 
    validated.
    
    """
    
    sum = 0
    double = True
    
    # Iterates til the last item of the list, adding to 
    # +sum the item and two times item, interspersed.
    for item in reversed(list):
        if double:
            item *= 2
            
            if item > 9:  # Casting out nines
                item -= 9
        
        sum += item
        double = not double
    
    mod = sum % 10
    
    # sum must be a multiple of 10. If it is, zero is 
    # +returned. Else, got to calculate how many numbers 
    # +are missing until 10.
    if mod:
        return 10 - mod
    
    else:
        return mod