#!/usr/bin/env python3

# this file is linked to unittest testing
# Python 3 Implementation of the Luhn Algorithm
# Checks to see if 14, 15 or 16 digit account number is Luhn Compliant.  
# See https://en.wikipedia.org/wiki/Luhn_algorithm for formula details.  
# where cardNumber is an account number received as a string:

class aLuhn(object):
    def doLuhn(cardNumber):
        cardLength = str(cardNumber)
        try: 
            cardNumbers = int(cardNumber)
        except ValueError:
            return(False)
        cardLength = len(cardLength)
        everyOtherFromFarRightFor16 = [-2,-4,-6,-8,-10,-12,-14,-16]
        everyOtherFromFarRightFor15 = [-2,-4,-6,-8,-10,-12,-14]
        everyOddFromFarRightButOneFor15 = [-3,-5,-7,-9,-11,-13,-15]
        everyOddFromFarRightButOneFor14 = [-3,-5,-7,-9,-11,-13]
        testNumber = str(cardNumber)
        doubleList = []
        doubleSet = []
        addUpDoubles = 0
        addUpOthers = 0
        if (cardLength == 16):
            doubleList = everyOtherFromFarRightFor16
            addUpTheOddDigits = everyOddFromFarRightButOneFor15
        elif (cardLength == 15):
            doubleList = everyOtherFromFarRightFor15
            addUpTheOddDigits = everyOddFromFarRightButOneFor15
        elif (cardLength == 14):
            doubleList = everyOtherFromFarRightFor15
            addUpTheOddDigits = everyOddFromFarRightButOneFor14
        else:
            return(False)
        for each in doubleList:
            doubleThis = cardNumber[each]
            doubleThis = int(doubleThis) * 2
            nowDoubled = str(doubleThis)
            if (len(nowDoubled) == 1):
                nowDoubled = nowDoubled
                doubleSet.append(nowDoubled)
            else:
                db1, db2 = nowDoubled[0], nowDoubled[1]
                db1, db2 = int(db1), int(db2)
                dbladd = db1 + db2
                doubleSet.append(dbladd)
        for each in doubleSet:
            addUpDoubles += int(each)
        print('addUpDoubles:', addUpDoubles)
        for each in addUpTheOddDigits:
            addOther = cardNumber[each]
            otherToAdd = int(addOther)
            addUpOthers += otherToAdd
        print('addUpOthers:', addUpOthers)
        totalSum = int(addUpDoubles) + int(addUpOthers)
        print('totalSum:', totalSum)
        totalSumTimesNine = (totalSum * 9)
        modTheTotalSum = (totalSumTimesNine % 10)
        if (str(modTheTotalSum) == cardNumber[-1]):
            return(True)
        else:
            return(False)

@@ -818,45 +818,8 @@
 13%5D%0A
-        testNumber = str(cardNumber)%0A
     
@@ -906,24 +906,92 @@
 pOthers = 0%0A
+        # setup the counting variables for appropriate card lengths%0A
         if (
@@ -1458,32 +1458,72 @@
   return(False)%0A
+        # select the items for doubling%0A
         for each
@@ -1666,16 +1666,70 @@
 leThis)%0A
+            # add single digit items to the doubleSet%0A
         
@@ -1854,32 +1854,159 @@
           else:%0A
+                # add each digit of 2-digit items to each other %0A                # and then add each item to the the doubleSet%0A
                 
@@ -2248,44 +2248,52 @@
     
-print('addUpDoubles:', addUpD
+# add all items in together in the d
 ouble
-s)
+Set
 %0A   
@@ -2457,42 +2457,62 @@
     
-print('addUpOthers:', addUpOthers)
+# add all items left over from the original cardNumber
 %0A   
@@ -2576,23 +2576,23 @@
     
-print('
+# take 
 totalSum
 :', 
@@ -2591,21 +2591,52 @@
 lSum
-:', totalSum)
+ * 9, then take Modulus of that number by 10
 %0A   
@@ -2725,16 +2725,88 @@
 e %25 10)%0A
+        # compare modTheTotalSum to the right-most digit in cardNumber %0A
         

Add Comments, remove quick test print statements