0

# Credit Card Validator

Somebody please tell me why the hell is my code not able to execute the subtraction form 9. https://code.sololearn.com/cfKQ7W1cirX5/?ref=app

8th May 2023, 12:05 PM
Ayush Ghara
7 ответов
+ 7
Ayush Ghara , some comments to the code: (1) as already mentioned the digits should be converted to int values. this an be done in the same step when reversing the input. then adapt the code according the new data format. (2) the multiplication of the digits should not start at index 0 but from index 1 with a step of 2. (3) the code has an issue when subtracting 9 from all numbers higher than 9. the current code does apply this to the variable *z*, which is not correct. we have to apply it to the list *a*. (similar to the step when multiplying each second number by 2) (4) finally we have to apply a *modulo division by 10* to the sum of the digits. the code uses *modulo 2* instead. as already mentioned the code line 22 should be corrected.
8th May 2023, 5:14 PM
Lothar
+ 5
Orin Cook , the task description can be found in the *community section*, *code coach exercises* and has the name *credit card validator*
8th May 2023, 4:05 PM
Lothar
+ 4
What is your input? edit: According to you by int(z) > 9 : false always.. what is the digit which is greater than 9?
8th May 2023, 1:42 PM
Jayakrishna 🇮🇳
+ 3
Lothar I know this, but learning to ask better questions is also an important part of everyone's education here. If op doesn't care enough about getting an answer to provide that info, I certainly don't care enough to look it up for him.
8th May 2023, 7:20 PM
Orin Cook
+ 3
Two more notes. Minor ones, I must say. 1. Rethink the logic of this block: if len(a)==16: pass else: print("not valid") You only have one action (print). Why both if and else? 2. Use meaningful variable and function names. They help explain your logic to the reader.
9th May 2023, 12:50 AM