human
Rearrange an array in maximum minimum form | Set 2 ( O ( 1 ) extra space ) | Prints max at first position , min at second position second max at third position , second min at fourth position and so on ..
initialize index of first minimum and first maximum element.
traverse array elements.
at even index : we have to put maximum element.
at odd index : we have to put minimum element.
Driver code"
How can the above be solved in Python?

What is a code to rearrange an array in maximum minimum form and the other steps required?
assistant
#Here is code to rearrange an array in maximum minimum form and the other steps required.
 def rearrange ( arr , n ) :
	max_ele = arr [ n - 1 ]
	min_ele = arr [ 0 ]
	for i in range ( n ) :
		if i % 2 == 0 :
			arr [ i ] = max_ele
			max_ele -= 1
		else :
			arr [ i ] = min_ele
			min_ele += 1
arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
n = len ( arr )
print ( " Origianl ▁ Array " )
for i in range ( n ) :
	print ( arr [ i ] , end = " ▁ " )
rearrange ( arr , n )
print ( " Modified Array " )
for i in range ( n ) :
	print ( arr [ i ] , end = " ▁ " )