def patterns(string):
   #Initialize count to 0
   count=0
   #Traverse till index len(string)-2
   for i in range(0,len(string)-2):
       #If 1st and 3rd letters matched and 1st and 2nd letters doesn't matched
       if string[i]==string[i+2] and string[i]!=string[i+1]:
           #Increment the count
           count+=1
   #return the count
   return count
#Function calling
first = 'axab'
print(patterns(first))
second = 'cdcece'
print(patterns(second))
71bdbf99e443d8d8546a100db1b593b99ebd32ce
<mask token>

def patterns(string):
    count = 0
    for i in range(0, len(string) - 2):
        if string[i] == string[i + 2] and string[i] != string[i + 1]:
            count += 1
    return count


<mask token>

def patterns(string):
    count = 0
    for i in range(0, len(string) - 2):
        if string[i] == string[i + 2] and string[i] != string[i + 1]:
            count += 1
    return count


<mask token>
print(patterns(first))
<mask token>
print(patterns(second))

def patterns(string):
    count = 0
    for i in range(0, len(string) - 2):
        if string[i] == string[i + 2] and string[i] != string[i + 1]:
            count += 1
    return count


first = 'axab'
print(patterns(first))
second = 'cdcece'
print(patterns(second))

def patterns(string):
   #Initialize count to 0
   count=0
   #Traverse till index len(string)-2
   for i in range(0,len(string)-2):
       #If 1st and 3rd letters matched and 1st and 2nd letters doesn't matched
       if string[i]==string[i+2] and string[i]!=string[i+1]:
           #Increment the count
           count+=1
   #return the count
   return count
#Function calling
first = 'axab'
print(patterns(first))
second = 'cdcece'
print(patterns(second))