human
Give me a code to equilibrium index of an array and the other steps required given the following:
Equilibrium index of an array | Python program to find the equilibrium index of an array Function to find the equilibrium index.
Iterate from 0 to len ( arr ).
If i is not 0.
Iterate from 0 to len ( arr ).
If no equilibrium index found , then return - 1.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to equilibrium index of an array and the other steps required.
 def equilibrium ( arr ) :
	left_sum = [ ]
	right_sum = [ ]
	for i in range ( len ( arr ) ) :
		if ( i ) :
			left_sum . append ( left_sum [ i - 1 ] + arr [ i ] )
			right_sum . append ( right_sum [ i - 1 ] + arr [ len ( arr ) - 1 - i ] )
		else :
			left_sum . append ( arr [ i ] )
			right_sum . append ( arr [ len ( arr ) - 1 ] )
	for i in range ( len ( arr ) ) :
		if ( left_sum [ i ] == right_sum [ len ( arr ) - 1 - i ] ) :
			return ( i )
	return - 1
arr = [ - 7 , 1 , 5 , 2 , - 4 , 3 , 0 ]
print ( ' First ▁ equilibrium ▁ index ▁ is ▁ ' , equilibrium ( arr ) )