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