We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
number = int(raw_input())
for k in range(1,number+1):
string = raw_input().strip()
i = len(string) -1 # scan for two consecutive
del_count = 0 #characters, if found increase
while i >0: #delete count
if string[i] == string[i-1]:
del_count = del_count+1
i = i-1
print del_count
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Alternating Characters
You are viewing a single comment's thread. Return to all comments →
number = int(raw_input()) for k in range(1,number+1): string = raw_input().strip() i = len(string) -1 # scan for two consecutive del_count = 0 #characters, if found increase while i >0: #delete count if string[i] == string[i-1]: del_count = del_count+1 i = i-1