Help me in solving SNELECTP problem

My issue

the output is correct still it’s wrong answer what cases i have failed

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 my c++ code for better understanding of the logic
ping me in case u get stuck at any point

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    string s;
	    cin>>s;
	    int cnt=0;
	    map<int,int> mp;
	    for(int i=0;i<s.size();i++)
	    {
	        if(s[i]=='m')
	        {
	            int j=i;
	            while(i<s.size()&&s[i]=='m')
	            {
	                i++;
	            }
	            if(i-j==1)
	            {
	                if(j>0&&mp[j-1]==0)
	                mp[j-1]=1;
	                else
	                mp[i]=1;
	            }
	            else
	            {
	                mp[i]=1;
	           if(mp[j-1]!=1)
	            mp[j-1]=1;
	            }
	        
	        }
	    }
	    for(int i=0;i<s.size();i++)
	    {
	        if(mp[i]==1)
	        continue;
	        if(s[i]=='m')
	        cnt++;
	        else
	        cnt--;
	    }
	    if(cnt>0)
	    cout<<"mongooses";
	    else if(cnt<0)
	    cout<<"snakes";
	    else
	    cout<<"tie";
	    cout<<endl;
	}

}