Implement the Luhn Algorithm - Test #3

Hi,

Test #3 in the Luhn Algorithm exercise says that “4111-1111-1111-1111“ should return “VALID!”. However, the total sum is 27 which is not a multiple of 10. Am I missing something here?

I attach some outputs from my verify_card_number function corresponding to the four test cases of the exercise (2, 3, 4 and 5). In each block is printed (from top to bottom): the list of integers corresponding to the input card number, the resulting digit-transformation list, the total sum of the digit-transformation list, and the actual return value.

please share the link to the project

you are doubling the wrong digits.

the one on the immediate left of the check digit needs to be doubled, you are not doubling that one, instead you are doubling the check digit

you need to double the second-to-last, fourth-to-last and so on, that’s what it means with “Starting from the right, and excluding the rightmost digit (the check digit), double the value of every other digit.”

that ends doubling the 4, and you get the correct result

I see! Thank you very much. I was transforming the digits from left to right instead of from right to left.