+ 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
5 odpowiedzi
+ 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.
+ 2
and you checked the length == 16?
for me this code works:
https://sololearn.com/compiler-playground/c4KsrvISPqLX/?ref=app
+ 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
+ 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.
0
Hello Denise Roßberg I've tried removing lines 15 and 16 but the response won't change