def clean_output(s):
 return re.sub('\n( *\n)+', '\n', s).replace('    ', '  ')

def clean_output ( s ) : return re . sub ( '\n( *\n)+' , '\n' , s ) . replace ( '    ' , '  ' )
remove double newlines with whitespace in between and reduce the level of indentation .