What is wrong in this code, I'm getting 6,7 compilation error? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

What is wrong in this code, I'm getting 6,7 compilation error?

#code by sanjay kazi. def rev(z): # function to reverse string or list return z[::-1] num = str(input()) t = list(rev(num)) p = [] for l in t: p.append(int(l)) # p is inverted list of input for i in range(len(p)): if (i+1)%2==0: p[i] = p[i]*2 # multiplies every 2nd number with 2 for j in range(len(p)): if p[j] > 9: p[j] = p[j]-9 # substraction of 9 from numbers greater than 9 sum = 0 for k in p: sum = sum + k if sum % 10 == 0: print("valid") else: print("not valid")

18th May 2020, 7:08 AM
Sanjay Kazi
Sanjay Kazi - avatar
5 Antworten
0
Hi can you please specify what are the inputs , and what are the outputs?
18th May 2020, 7:17 AM
Abhay
Abhay - avatar
0
Actually its a challenge problem and 5 cases are satisfied but last two case are producing error.
18th May 2020, 7:32 AM
Sanjay Kazi
Sanjay Kazi - avatar
0
You can find it in medium level challenge problem. "Credit card validator "
18th May 2020, 7:33 AM
Sanjay Kazi
Sanjay Kazi - avatar
0
You should then add code coach in the tags,also reframe your question like why the last two 6 and 7 test cases are failing ,I think it's a pro question so I can't help further
18th May 2020, 8:07 AM
Abhay
Abhay - avatar
0
Okay cool
18th May 2020, 8:10 AM
Sanjay Kazi
Sanjay Kazi - avatar