human
Print Postorder traversal from given Inorder and Preorder traversals | A utility function to search x in arr [ ] of size n.
Prints postorder traversal from given inorder and preorder traversals.
The first element in pre [ ] is always root , search it in in [ ] to find left and right subtrees.
If left subtree is not empty , print left subtree.
If right subtree is not empty , print right subtree.
Print root.
Driver code"
How can the above be solved in Python?

Give me a code to print Postorder traversal from given Inorder and Preorder traversals and the other steps required?
assistant
#Here is code to print Postorder traversal from given Inorder and Preorder traversals and the other steps required.
 def search ( arr , x , n ) :
	for i in range ( n ) :
		if ( arr [ i ] == x ) :
			return i
	return - 1
def printPostOrder ( In , pre , n ) :
	root = search ( In , pre [ 0 ] , n )
	if ( root != 0 ) :
		printPostOrder ( In , pre [ 1 : n ] , root )
	if ( root != n - 1 ) :
		printPostOrder ( In [ root + 1 : n ] , pre [ root + 1 : n ] , n - root - 1 )
	print ( pre [ 0 ] , end = " ▁ " )
In = [ 4 , 2 , 5 , 1 , 3 , 6 ]
pre = [ 1 , 2 , 4 , 5 , 3 , 6 ]
n = len ( In )
print ( " Postorder ▁ traversal ▁ " )
printPostOrder ( In , pre , n )