centralize the printed output in python using shutil
import shutil def print_centered(text): screen_width = shutil.get_terminal_size().columns text_width = len(text) left_margin = (screen_width - text_width) // 2 print(' ' * left_margin, text) print_centered('Hello, World!')