+ 1

#CREDIT CARD VALIDATOR

Again, I wrote this code in an attempt to solve a code coach but test case #6 and #7 won't acknowledge it.However, I believe I shouldn't get myself frustrated knowing that you are always there to lend a hand when needed. Kindly have a look at it. https://sololearn.com/compiler-playground/ccN2JwwG9IvH/?ref=app

8th Jan 2025, 11:47 AM
Karlu
Karlu - avatar
5 Answers
+ 2
Hello Kambi Alii Kalu Remove line 15 and 16. Check the length at the end: if sum_of_numbers % 10== 0 and len(third_operation) == 16: print ("valid") else: print ("not valid") by the way, you should not insert your own print statements. If only “valid” or “not valid” is expected, deviating print statements will always cause an error.
8th Jan 2025, 1:33 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
and you checked the length == 16? for me this code works: https://sololearn.com/compiler-playground/c4KsrvISPqLX/?ref=app
8th Jan 2025, 4:31 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Thanks brother Denise Roßberg it works indeed...and the information you gave about not including print statements that are not in question is really valuable
8th Jan 2025, 5:08 PM
Karlu
Karlu - avatar
+ 2
sorry for my late response. just an idea for improving the code, even if it runs properly: regardless of the correct solution to this task, the question arises why the *length* of the credit card number is only checked at the very end of the code. if the length is not correct, then all the required processing steps are useless. in my opinion, the length should be checked directly after getting the user input.
16th Mar 2025, 7:31 PM
Lothar
Lothar - avatar
0
Hello Denise Roßberg I've tried removing lines 15 and 16 but the response won't change
8th Jan 2025, 3:44 PM
Karlu
Karlu - avatar