I'm trying to count every time a string appears in a given string
I'm trying to count the number of times 'BB' or 'EE' appear, for example BB would give 1, and BBB would give 2 from 'BB'B and B'BB'. How can I shorten this down? I tried using count
but it only counts it once.
s=input()
for i in range(len(s)+1):
if i>1:
if s[i-2:i]=='BB':
a+=1
if s[i-2:i]=='EE':
b+=1