human
Smallest greater elements in whole array | Simple Python3 program to find smallest greater element in whole array for every element ..
Find the closest greater element for arr [ j ] in the entire array ..
Check if arr [ i ] is largest.
Driver code"
How can the above be solved in Python?

Can you provide a code to smallest greater elements in whole array and the other steps required?
assistant
#Here is code to smallest greater elements in whole array and the other steps required.
 def smallestGreater ( arr , n ) :
	for i in range ( 0 , n ) :
		diff = 1000 ;
		closest = - 1 ;
		for j in range ( 0 , n ) :
			if ( arr [ i ] < arr [ j ] and arr [ j ] - arr [ i ] < diff ) :
				diff = arr [ j ] - arr [ i ] ;
				closest = j ;
		if ( closest == - 1 ) :
			print ( " _ ▁ " , end = " " ) ;
		else :
			print ( " { } ▁ " . format ( arr [ closest ] ) , end = " " ) ;
ar = [ 6 , 3 , 9 , 8 , 10 , 2 , 1 , 15 , 7 ] ;
n = len ( ar ) ;
smallestGreater ( ar , n ) ;