run time error

can i know why i’m getting run time error for COOMILK program

c=0
m='cookie'
n='milk'
for i in range(int(input())):
    h=input()
    l1=list(input().split())
    for j in range(len(l1)-1):
        if l1[j]==m and l1[j+1]!=n:
            c=l
        break
if c==0 and l1[-1]==n:
    print("YES")
else:
    print("NO")

l1[-1]==n

Can you access the -1st element of the array?

Think about it!!

l1[-1] means the last element in python -__-

please select your code and then click on 10101 above this will allign your code properly.

Ahh, my bad!! I didn’t know that

c=l

Make it c=l1 . Also, you are printing output for only 1 T . Meaning, out of T test cases, you are printing output of only 1. Make the print statement inside loop as well.