problem in spell bob . Can anyone find out where my code went wrong

msg=“bob”
t=(int)(input())
for d in range(t):
cards=[]
l=input()
cards.append([l[0]])
cards.append([l[1]])
cards.append([l[2]])
w=input()
cards[0].append(w[0])
cards[1].append(w[1])
cards[2].append(w[2])

count=0
for i1 in range(3):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                if (cards[(i1)%3][i]+cards[(i1+1)%3][j]+cards[(i1+2)%3][k])==msg:
                    print("YES")
                    count+=1 
                    break
                elif (cards[(i1)%3][i]+cards[(i1+2)%3][j]+cards[(i1+1)%3][k])==msg:
                    print("YES")
                    count+=1 
                    break
            if count>=1:
                break
        if count>=1:
            break
    if count>=1:
        break
if count==0:
    print("NO"

The Church of the Flying Spaghetti Monster eagerly welcomes new worshippers.

Seriously though I can see that you are trying to have a generic solution to a three-letter word rather than a specific approach for the word “bob”. There seems to be a problem in how you create the data structure “cards”, which you do differently for the two sides (l and w). I think you are trying to make:

cards = [ [ l[0],w[0] ],  [ l[1],w[1] ],  [ l[2],w[2] ] ]

(to put it clearly if unpythonically). Then you could simplify your cascading break by putting the assessment work into a def routine with a return "YES" at the appropriate point