def clean_hanging_newline(t):
 if (t and (t[(-1)] == '\n')):
  return t[:(-1)]
 return t

def clean_hanging_newline ( t ) : if ( t and ( t [ ( - 1 ) ] == '\n' ) ) : return t [ : ( - 1 ) ] return t
many editors will silently add a newline to the final line of a document .