Text Alignment

  • + 0 comments

    Below code creates the absolute representation of H as shown in figure. but still not passing.

    thickness = int(input()) # Odd number c = 'H' t=thickness

    Top Cone

    for i in range(thickness): print((" "*(t-i))+((c * (2 * i + 1)).ljust(thickness * 5))) t=thickness

    Top Pillars

    for i in range(thickness + 1): print((" "*((thickness//2)+1))+(c * thickness + ' ' * (thickness * 3) + c * thickness).center(thickness * 5))

    Middle Belt

    for i in range((thickness + 1) // 2): print((" "*((thickness//2)+1))+(c * thickness * 5).center(thickness * 5))

    Bottom Pillars

    for i in range(thickness + 1): print((" "*((thickness//2)+1))+(c * thickness + ' ' * (thickness * 3) + c * thickness).center(thickness * 5))

    Bottom Cone

    for i in range(thickness): print((" "*((thickness*3)+1))+(" "*(thickness + i)) + (c * (2 * (thickness - i) - 1)).ljust(thickness * 5))