def format_str_for_message(msg_str):
 lines = msg_str.splitlines()
 num_lines = len(lines)
 sr = '\n'.join(lines)
 if (num_lines == 0):
  return ''
 elif (num_lines == 1):
  return (' ' + sr)
 else:
  return ('\n' + sr)

def format_str_for_message ( msg_str ) : lines = msg_str . splitlines ( ) num_lines = len ( lines ) sr = '\n' . join ( lines ) if ( num_lines == 0 ) : return '' elif ( num_lines == 1 ) : return ( ' ' + sr ) else : return ( '\n' + sr )
format msg_str so that it can be appended to a message .