curriculum/challenges/english/blocks/learn-how-to-work-with-numbers-and-strings-by-implementing-the-luhn-algorithm/656879a66338b2a461d5d307.md
The Luhn algorithm is as follows:
Assume an example of an account number "7992739871" that will have a check digit added, making it of the form 7992739871x:
Account number 7 9 9 2 7 3 9 8 7 1 x
Double every other 7 18 9 4 7 6 9 16 7 2 x
Sum 2-char digits 7 9 9 4 7 6 9 7 7 2 x
Replace the pass statement with a variable sum_of_odd_digits and a value of 0.
You should have sum_of_odd_digits = 0 within the verify_card_number function.
({
test: () => {
const transformedCode = code.replace(/\r/g, "");
const verify_card_number = __helpers.python.getDef("\n" + transformedCode, "verify_card_number");
const { function_body } = verify_card_number;
assert.match(function_body, /sum_of_odd_digits\s*=\s*0/);
}
})
You should not have pass within the verify_card_number function.
({
test: () => {
const transformedCode = code.replace(/\r/g, "");
const verify_card_number = __helpers.python.getDef("\n" + transformedCode, "verify_card_number");
const { function_body } = verify_card_number;
assert.notMatch(function_body, /pass/);
}
})
--fcc-editable-region--
def verify_card_number(card_number):
pass
--fcc-editable-region--
def main():
card_number = '4111-1111-4555-1142'
card_translation = str.maketrans({'-': '', ' ': ''})
translated_card_number = card_number.translate(card_translation)
print(translated_card_number)
verify_card_number(translated_card_number)
main()