Help me in solving AO15 problem

My issue

Status :Time limit exceeded

My code

# this code has some logical error - debug this code to solve the problem

t = int(input())
for i in range(t):
    n = int(input())
    A = list(map(int,input().split()))
    
    count_neg = 0
    count_zero = A.count(0)
    
    if count_zero > 0:
        print(0)
    else:
        i = 0
        while i<n:
            if A[i] < 0:
                count_neg = count_neg + 1
        i = i + 1
        
        if count_neg%2 == 0:
            print(0)
        else:
            print(1)

Learning course: Solve Programming problems using Python
Problem Link: CodeChef: Practical coding for everyone

@janaranjini

Just by adding the else condition beneath the nested if condition solves the problem. Rest of the conditions and printed values were correct.

In your code, you have changed the values to be printed in nested if-else.

Here is my code for reference.

# this code has some logical error - debug this code to solve the problem

t = int(input())
for i in range(t):
    n = int(input())
    A = list(map(int,input().split()))
    
    count_neg = 0
    count_zero = A.count(0)
    
    if count_zero > 0:
        print(0)
    else:
        i = 0
        while i<n:
            if A[i] < 0:
                count_neg = count_neg + 1
            i = i + 1
        
        if count_neg%2 != 0:
            print(1)
        else:    #added this condition
            print(0)