def restack(stack, index=0):
 x = stack.pop(index)
 stack.append(x)
 return x

def restack ( stack , index = 0 ) : x = stack . pop ( index ) stack . append ( x ) return x
returns the element at index after moving it to the top of stack .