Python Program to Print H Star Pattern

Write a Python program to print H star pattern using for loop.

```rows = int(input("Enter H Star Pattern Rows = "))

print("====The H Star Pattern====")

for i in range(1, rows + 1):
for j in range(1, i + 1):
print('*', end = '')
for k in range(i * 2, rows * 2):
print(end = ' ')
for l in range(1, i + 1):
print('*', end = '')
print()

for i in range(1, rows):
for j in range(rows - 1, i - 1, -1):
print('*', end = '')
for k in range(1, i * 2 + 1):
print(end = ' ')
for l in range(rows - 1, i - 1, -1):
print('*', end = '')
print()```
``````Enter H Star Pattern Rows = 8
====The H Star Pattern====
*              *
**            **
***          ***
****        ****
*****      *****
******    ******
*******  *******
****************
*******  *******
******    ******
*****      *****
****        ****
***          ***
**            **
*              *``````

In this Python example, we created multiple functions that run the repeated for loops to print the alphabet H star pattern.

```def firstloop(i):
for j in range(1, i + 1):
print('*', end = '')

def secondloop(rows, i):
for j in range(rows - 1, i - 1, -1):
print('*', end = '')

rows = int(input("Enter H Star Pattern Rows = "))

print("====The H Star Pattern====")
for i in range(1, rows + 1):
firstloop(i)
for k in range(i * 2, rows * 2):
print(end = ' ')
firstloop(i)
print()

for i in range(1, rows):
secondloop(rows, i)
for k in range(1, i * 2 + 1):
print(end = ' ')
secondloop(rows, i)
print()```

This Python program allows the user to enter the character and print the given character’s alphabet H pattern.

```def firstloop(i, ch):
for j in range(1, i + 1):
print('%c' %ch, end = '')

def secondloop(rows, i, ch):
for j in range(rows - 1, i - 1, -1):
print('%c' %ch, end = '')

rows = int(input("Enter H Star Pattern Rows = "))
ch = input("Symbol to use in H Pattern = " )
print("====The H Star Pattern====")

for i in range(1, rows + 1):
firstloop(i, ch)
for k in range(i * 2, rows * 2):
print(end = ' ')
firstloop(i, ch)
print()

for i in range(1, rows):
secondloop(rows, i, ch)
for k in range(1, i * 2 + 1):
print(end = ' ')
secondloop(rows, i, ch)
print()```
``````Enter H Star Pattern Rows = 13
Symbol to use in H Pattern = \$
====The H Star Pattern====
\$                        \$
\$\$                      \$\$
\$\$\$                    \$\$\$
\$\$\$\$                  \$\$\$\$
\$\$\$\$\$                \$\$\$\$\$
\$\$\$\$\$\$              \$\$\$\$\$\$
\$\$\$\$\$\$\$            \$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$          \$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$        \$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$\$      \$\$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$\$\$    \$\$\$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$\$\$\$  \$\$\$\$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$\$\$\$  \$\$\$\$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$\$\$    \$\$\$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$\$      \$\$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$\$        \$\$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$\$          \$\$\$\$\$\$\$\$
\$\$\$\$\$\$\$            \$\$\$\$\$\$\$
\$\$\$\$\$\$              \$\$\$\$\$\$
\$\$\$\$\$                \$\$\$\$\$
\$\$\$\$                  \$\$\$\$
\$\$\$                    \$\$\$
\$\$                      \$\$
\$                        \$``````