dongsubak
3/3/2019 - 8:21 AM

Alternating Characters

def alternatingCharacters(s):
    res = 0
    for char in range(1,len(s)):
        if(s[char] == s[char-1]):
            res += 1
    return res
    
        def alternatingCharacters(s):
          return sum(s[i]==s[i+1]for i in range(len(s)-1))
          
          return sum(1 for i in xrange(len(s)-1) if s[i] == s[i+1])