Text Alignment

  • + 0 comments

    n = int(input())

    Top corner

    times = 1 space = 1 + (n - 1) * 2 indent = int((space - n) / 2)

    for x in range(n): # Top triangle print(("H" * times).center(space, ' ')) times += 2

    6 rows of 5 H columns for the top

    for x in range(6):
    print(" " * indent, end="") print("H" * n + " " * (n * 3) + "H" * n)

    Middle (big lines)

    row = n // 2 + 1 for x in range(row): # Center section print(" " * indent, end="") print("H" * (n * 5))

    6 rows of 5 H columns for the bottom

    for x in range(6):
    print(" " * indent, end="") print("H" * n + " " * (n * 3) + "H" * n)

    Bottom corner

    fakespace = space for x in range(n): # Bottom triangle print(" " * indent + " " * n + " " * (n * 3 - indent), end="") print(("H" * fakespace).center(space, ' ')) fakespace -= 2