Analysing Python Code

PLEASE CLARIFY WHAT IS THE ERROR IN THIS CODE (PROBLEM CODE-BALLOON)
t=int(input())
for i in range(t):
n=int(input())
l=list(map(int,input().split()))
c=0
for j in range(0,n):
if ((l[j]<=7 and l[j]>=1) or j<=6):
c+=1
print(c)

t = int(input())  # Number of test cases
for _ in range(t):
    n = int(input())  # Number of balloons
    l = list(map(int, input().split()))  # List of balloon heights
    c = 0  # Counter for balloons satisfying conditions

    for j in range(n):
        if (l[j] <= 7 and l[j] >= 1) or j < 7:
            c += 1

    print(c)

This is the correct code, I have fixed the input parsing logic and the logic working.

NOTE:
from the next time please provide a proper indentation code, it is very hard to know where is the problem when you don’t know what is in the loop and what is not.