Text Alignment

Sort by

recency

|

462 Discussions

|

  • + 0 comments

    change language to python3 and try this code

    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

    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))

    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

  • + 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

  • + 0 comments

    for those who can't find the partial code: at the top change language to python 3

  • + 0 comments

    Somehow, i made the test 0 worked, but not the others, can anyone tell where is wrong? n = int(input()) for i in range(1,n+1): print(('H'*(2*i-1)).center(2*n-1,' ')) for i in range(0,n+1): print(('H'*n).center(2*n-1,' '),('H'*n).center(6*n,' ')) for i in range(0,n-2): print(('H'*5*n).rjust(5*n+2,' ')) for i in range(0,n+1): print(('H'*n).center(2*n-1,' '),('H'*n).center(6*n,' ')) for i in range(1,n+1): print(('H'*(2*n-(2*i-1))).rjust((5*n+5)-i,' '))

  • + 1 comment

    Is anyone else not getting any sample code? mine just says "Enter your code here. Read input from STDIN. Print output to STDOUT". i've refreshed it and reset the code but nothing