Here's the copied code (added count += 1 after else-clause to make sure it completes):
list=['a','a','x','c','e','e','f','f','f'] i=0 count = 0 while count < len(list)-2: if list[i] == list[i+1]: if list [i+1] != list [i+2]: print list[i] i+=1 count +=1 else: print "no" count += 1 else: i +=1 count += 1
A more advanced solution using itertools is more compact and simpler in law:
from itertools import groupby data = ['a','a','x','c','e','e','f','f','f'] for k, g in groupby(data): if len(list(g)) > 1: print k
source share