human
Equilibrium index of an array | function to find the equilibrium index.
Check for indexes one by one until an equilibrium index is found.
get left sum.
get right sum.
if leftsum and rightsum are same , then we are done.
return - 1 if no equilibrium index is found.
driver code"
How can the above be solved in Python?
 Write me a code to equilibrium index of an array and the other steps required?
assistant
#Here is code to equilibrium index of an array and the other steps required.
 def equilibrium ( arr ) :
	leftsum = 0
	rightsum = 0
	n = len ( arr )
	for i in range ( n ) :
		leftsum = 0
		rightsum = 0
		for j in range ( i ) :
			leftsum += arr [ j ]
		for j in range ( i + 1 , n ) :
			rightsum += arr [ j ]
		if leftsum == rightsum :
			return i
	return - 1
arr = [ - 7 , 1 , 5 , 2 , - 4 , 3 , 0 ]
print ( equilibrium ( arr ) )