+ 1

Luhn Formula - CC Validator

https://code.sololearn.com/cd7IZRSsbLNi/?ref=app It's passing 4/7 tests. When I test to print the sum, it's coming out wrong. For example, the first test case the sum should be a multiple of 10 to print valid, but it's coming out as 59.

27th Nov 2022, 3:25 PM
Anna Swann
Anna Swann - avatar
5 Answers
+ 10
Anna Swann , there is a small issue in the second step of the calculation, where we should multiply each second digit by 2. #for num in range(0, len(holder2), 2): # your code starts with the first digit for num in range(1, len(holder2), 2): # this should work since it starts with the second digit > scroll down in the task description to the bottom - have a look at the sample ...
27th Nov 2022, 4:13 PM
Lothar
Lothar - avatar
+ 6
Lochard , > in the bottom of the app you can see the section *community*. click on it > there you can find the *code coach*. in this section click on *view more* > all the code coach exercises will be shown as an overview. use search bar on top, input *credit card* > click on this item, then you will see the task description and also the code editor
29th Nov 2022, 5:44 PM
Lothar
Lothar - avatar
+ 3
Thank you, Lothar! That worked!
27th Nov 2022, 4:40 PM
Anna Swann
Anna Swann - avatar
+ 1
@Lothar May I ask how to see the task description?
28th Nov 2022, 5:07 PM
Lochard
Lochard - avatar
0
I can see your code but I cannot see the question. I looked up Luhn Formula, it seems quite different from your code.
27th Nov 2022, 3:53 PM
Lochard
Lochard - avatar