Help me in solving SNELECTP problem

My issue

explain what’s wrong in this question the output is correct still at submit it shows wrong

My code

# cook your dish here
t=int(input())
for i in range(t):
    l=str(input())
    j=0
    l1=[""]
    
    for i in range(len(l)):
        l1.append(l[i])
    while j<(len(l1)-1):
        if l1[j+1]=="m" and l1[j]=="s":
            l1[j]=""
            j=j+1
        j=j+1
    
    
    k=0
    while k<(len(l1)-1):
        if l1[k-1]!="" and l1[k]=="m" and l1[k+1]=="s":
            l1[k+1]=""
            k+=1
        k+=1
        
  
    if l1.count("s")>l1.count("m"):
        print("snakes")
    elif l1.count("s")<l1.count("m"):
        print("mongooses")
    else:
        print("tie")

Learning course: Greedy Algorithms
Problem Link: Snakes, Mongooses and the Ultimate Election Practice Problem in Greedy Algorithms - CodeChef

@meghasyam21
plzz refer the following code

T = int(input())
for _ in range(T):
    s = input()
    n = len(s)
    killed = [False] * n

    for i in range(n):
        if s[i] == 'm':
            if i - 1 >= 0 and s[i - 1] == 's' and not killed[i - 1]:
                killed[i - 1] = True
                continue
            if i + 1 < n and s[i + 1] == 's':
                killed[i + 1] = True

    snakes = 0
    mongooses = 0

    for i in range(n):
        if s[i] == 's' and not killed[i]:
            snakes += 1
        if s[i] == 'm':
            mongooses += 1

    ans = "tie"
    if snakes > mongooses:
        ans = "snakes"
    elif mongooses > snakes:
        ans = "mongooses"

    print(ans)