Help me in solving PREQ40 problem

My issue

ghgv

My code

# Update the code below to solve the problem

t = int(input())  # Number of test cases
for _ in range(t):
    S = input().strip()  # Input string
    count = 0
    for i in range(1,len(S)):
        if i >0 and S[i] == S[i - 1]:
            count += 1
    print(count)
    S = input()
    

Learning course: Design and Analysis of Algorithms
Problem Link: Practice problem - Different Consecutive Chars in Design and Analysis of Algorithms
strong text