# Sum of vector in python

I will take input an integer n and take input in n line separated by space.Every line it contains the value of vector(x,y,z). If the sum of vector is 0 then i will print “YES” and if it’s not then print “NO”.
Input:

The first line contains a positive integer n (1 ≤ n ≤ 100), then follow n lines containing three integers each: the x i coordinate, the y i coordinate and the z i coordinate of the force vector, applied to the body ( - 100 ≤ x i , y i , z i ≤ 100).

Output:

Print the word “YES” if the body is in equilibrium, or the word “NO” if it is not.

Examples
input:

``````3
4 1 7
-2 4 -1
1 -5 -3
``````

output:

``````NO
``````

input:

``````3
3 -1 7
-5 2 -4
2 -1 -3
``````

output:

``````YES
``````

Here is my code:

``````n = int(input())
c = 0
for x in range(n):
a = list(map(int,input().split()))
c = c + sum(a)
if c == 0:
print("YES")
else:
print("NO")
``````

But i got WRONG ANSWER in test case 81.According to this,

Original problem is here.
I don’t want the solution.Just help me to understand what’s going on?

I believe that you need to sum each column. You have a sum of all values, but you need an x sum, a y sum, and a z sum.

1 Like