def center_text(text, length=80, left_edge='|', right_edge='|', text_length=None):
 if (text_length is None):
  text_length = get_text_length(text)
 output = []
 char_start = (((length // 2) - (text_length // 2)) - 1)
 output.append(((left_edge + (' ' * char_start)) + text))
 length_so_far = ((get_text_length(left_edge) + char_start) + text_length)
 right_side_spaces = ((length - get_text_length(right_edge)) - length_so_far)
 output.append((' ' * right_side_spaces))
 output.append(right_edge)
 final = ''.join(output)
 return final

def center_text ( text , length = 80 , left_edge = '|' , right_edge = '|' , text_length = None ) : if ( text_length is None ) : text_length = get_text_length ( text ) output = [ ] char_start = ( ( ( length // 2 ) - ( text_length // 2 ) ) - 1 ) output . append ( ( ( left_edge + ( ' ' * char_start ) ) + text ) ) length_so_far = ( ( get_text_length ( left_edge ) + char_start ) + text_length ) right_side_spaces = ( ( length - get_text_length ( right_edge ) ) - length_so_far ) output . append ( ( ' ' * right_side_spaces ) ) output . append ( right_edge ) final = '' . join ( output ) return final
center text with specified edge chars .