PW Akshay

Generation

generate functionTue, 03 Jan 2023

centralize the printed output in python using shutil

import shutil def print_centered(text): screen_width = shutil.get_terminal_size().columns text_len = len(text) left_margin = (screen_width - text_len) // 2 print(' ' * left_margin, text)

Questions about programming?Chat with your personal AI assistant