human
Elements that occurred only once in the array | Function to find the elements that appeared only once in the array.
Check if the first and last element is equal If yes , remove those elements.
Start traversing the remaining elements.
Check if current element is equal to the element at immediate previous index If yes , check the same for next element.
Else print the current element.
Check for the last element.
Driver code"
How can the above be solved in Python?
 Write me a code to elements that occurred only once in the array and the other steps required?
assistant
#Here is code to elements that occurred only once in the array and the other steps required.
 def occurredOnce ( arr , n ) :
	i = 1
	len = n
	if arr [ 0 ] == arr [ len - 1 ] :
		i = 2
		len -= 1
	while i < n :
		if arr [ i ] == arr [ i - 1 ] :
			i += 1
		else :
			print ( arr [ i - 1 ] , end = " ▁ " )
		i += 1
	if ( arr [ n - 1 ] != arr [ 0 ] and arr [ n - 1 ] != arr [ n - 2 ] ) :
		print ( arr [ n - 1 ] )
if __name__ == " _ _ main _ _ " :
	arr = [ 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 ]
	n = len ( arr )
	occurredOnce ( arr , n )