You are viewing a single comment's thread. Return to all comments →
def alternatingCharacters(s): n = len(s) count = 0 for i in range(n-1): if s[i] == s[i+1]: count += 1 return count
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 →
def alternatingCharacters(s): n = len(s) count = 0 for i in range(n-1): if s[i] == s[i+1]: count += 1 return count