Alternating Characters

  • + 0 comments

    def alternatingCharacters(s):

    lp=count=0
    rp=1
    while lp<len(s) and rp<len(s):
        if s[lp]==s[rp]:
            count+=1
        lp+=1
        rp+=1
    return count