Help me in solving XYSTRP problem

My issue

can anyone explain what’s the problem with the code

My code

# cook your dish here
t=int(input())
for _ in range(t):
    s=input()
    num_pairs=0
    n=len(s)
    for i in range(n-1):
        if s[i]=='x' and s[i+1]=='y':
            num_pairs+=1
            i+=2
    print(num_pairs)

Learning course: Greedy Algorithms
Problem Link: https://www.codechef.com/learn/course/greedy-algorithms/LIGRDSA01/problems/XYSTRP

Hint
Try these test case:
4
yx
yxxy
xyyx
xyyxxyyxy