Same Two Programs but Different Results. WHY?

For problem code: HEADBOB

for i in range(int(input())):
n=int(input())
li=input()[:n]
if “Y” in li:
print(“NON INDIAN”)
elif “I” in li:
print(“INDIAN”)
else:
print(“NOT SURE”)

for this code I am getting wrong answer and for the the below code I am getting right answer.

t = int(input())
for i in range(t):
n = int(input())
s = input()[:n]
if “Y” in s:
print(“NOT INDIAN”)
elif “I” in s:
print(“INDIAN”)
else:
print(“NOT SURE”)

The only difference between the two is the first line of code and the different output doesn’t make any sense. Could you please explain me what’s happenning!?

In above code there’s “NON INDIAN” whereas in below, there’s “NOT INDIAN”

3 Likes