human
Check if the array has an element which is equal to XOR of remaining elements | Function that returns true if the array contains an element which is equal to the XOR of the remaining elements.
To store the XOR of all the array elements.
For every element of the array.
Take the XOR after excluding the current element.
If the XOR of the remaining elements is equal to the current element.
If no such element is found.
Driver Code"
How can the above be solved in Python?
 Write me a code to check if the array has an element which is equal to XOR of remaining elements and the other steps required?
assistant
#Here is code to check if the array has an element which is equal to XOR of remaining elements and the other steps required.
 def containsElement ( arr , n ) :
	xorArr = 0
	for i in range ( n ) :
		xorArr ^= arr [ i ]
	for i in range ( n ) :
		x = xorArr ^ arr [ i ]
		if ( arr [ i ] == x ) :
			return True
	return False
arr = [ 8 , 2 , 4 , 15 , 1 ]
n = len ( arr )
if ( containsElement ( arr , n ) ) :
	print ( " Yes " )
else :
	print ( " No " )