Python - Why do some test cases fail?

So, I am working on problems on hackerrank, I am new to python.

Information about what I'm trying to do is found here: https://www.hackerrank.com/challenges/compare-the-triplets?h_r=next-challenge&h_v=zen

a0,a1,a2 = input().strip().split(' ')
a0,a1,a2 = [int(a0),int(a1),int(a2)]
b0,b1,b2 = input().strip().split(' ')
b0,b1,b2 = [int(b0),int(b1),int(b2)]

a1 = 0
b1 = 0
lst1 = a0,a1,a2
lst2 = b0,b1,b2

for x, y in zip(lst1, lst2):
    if x > y:
        a1 += 1

    if x <y:
        b1 += 1

    else:
        pass

print(a1, b1)

So this works fine.

However, in one of the test cases, the input

6 8 12
7 9 15

and the conclusion should be

0 3

However, my code continues to fail. Why is this so?

+4
source share
2 answers

Perhaps you need to change the name varicale a1, b1 in the code to some other names.

....
a1 = 0
b1 = 0
...

They remove the input a1 / b1 as the same name, I do not understand why this is necessary :)

a0,a1,a2 = [int(a0),int(a1),int(a2)]
b0,b1,b2 = [int(b0),int(b1),int(b2)]
+3
source

2 . 1. . a1 a1 . 2. '{0} {1}'. Format (a1, b1) raw_input() input(), .

+4

Source: https://habr.com/ru/post/1657951/


All Articles