I think this is exactly what you need:
import os
COL, ROW = os.get_terminal_size()
def print_in_center(strings: list) -> None:
for index, string in enumerate(strings):
space_before_str = " " * ((COL - len(string)) // 2)
if index == 0:
center_row = "\n" * (ROW // 2 - len(strings))
print(center_row + space_before_str + string)
else:
print(space_before_str + string)
def input_in_center(string: str) -> str:
space_before_str: str = " " * ((COL - len(string)) // 2)
return input(space_before_str + string)
print_in_center(['Main Menu', 'Option[1]', 'Option[2]', 'Option[3]'])
input_in_center("Input an option number: ")
You can use the print_in_center function to pass strings in the form of a list (where each index is a new line) to the function and print the strings in the center of the page.