This Python program uses loops to draw the uppercase letter 'H' using the '*' character in the terminal.
The number of rows is taken as input and determines the height of the letter.
This exercise helps practice loop structures and conditional logic for rendering symmetrical text-based shapes.
def draw_letter_h(rows):
cols = rows
for i in range(rows):
for j in range(cols):
if j == 0 or j == cols - 1 or i == rows // 2:
print("*", end="")
else:
print(" ", end="")
print()
# Run the program
rows = int(input("Enter number of rows: "))
draw_letter_h(rows)
* *
* *
* *
*******
* *
* *
* *
- The outer loop controls the number of rows
- The inner loop prints characters across each column
- The first and last columns always contain asterisks
- The middle row is filled entirely with asterisks to form the horizontal bar of 'H'