convert x into a string and append it to a list, substitute the resulting list for out. join elements of out into a string, separated with whitespaces, append ')' to it, append the result to '(', return it.
return "(" + " " . join ( out ) + ")"