centralize the printed output in python using shutil
import shutil def print_centralized(string, symbol=1): """ print a string to the center of the terminal :param string: The string to print :param symbol: The width of the symbol (1 or 2) :return: None """ term_size = shutil.get_terminal_size() break_line = (term_size.columns - len(string)) // 2 if symbol == 1: begin = "| " + "-" * break_line end = "-" * break_line + " |" else: begin = "|-" + "-" * break_line end = "-" * break_line + "-|" print(begin + string + end)