human
Count consecutive pairs of same elements | Function to return the count of consecutive elements in the array which are equal.
If consecutive elements are same.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count consecutive pairs of same elements and the other steps required.
 def countCon ( ar , n ) :
	cnt = 0
	for i in range ( n - 1 ) :
		if ( ar [ i ] == ar [ i + 1 ] ) :
			cnt += 1
	return cnt
ar = [ 1 , 2 , 2 , 3 , 4 , 4 , 5 , 5 , 5 , 5 ]
n = len ( ar )
print ( countCon ( ar , n ) )