This article shows how to write a Python program to print the Alphabet E star pattern using the for loop, while loop, and functions with an example.
The below alphabet E star pattern example accepts the user-entered rows, and the nested for loop iterates the rows. The If else condition is to print stars at the first, middle, and last positions to get the Alphabet E pattern of stars and skip others.
rows = int(input("Enter Alphabet E of Stars Rows = "))
print("====The Alphabet E Star Pattern====")
for i in range(rows):
print('*', end='')
for j in range(rows):
if (i == 0 or i == rows - 1) or (i == rows // 2 and j <= rows // 2):
print('*', end='')
else:
continue
print()

Python program to print the Alphabet E Star pattern using while loop
Instead of a For loop, this program uses the while loop to iterate the Alphabet E pattern rows and prints the stars at each position. For more Star Pattern programs >> Click Here.
rows = int(input("Enter Alphabet E of Stars Rows = "))
i = 0
while i < rows:
print('*', end='')
j = 0
while j < rows:
if (i == 0 or i == rows - 1) or (i == rows // 2 and j <= rows // 2):
print('*', end='')
else:
j = j + 1
continue
j = j + 1
print()
i = i + 1
Enter Alphabet E of Stars Rows = 12
*************
*
*
*
*
*
********
*
*
*
*
*************
In this Program example, we created an EPattern function that accepts the rows and the symbol or character to print the Alphabet E pattern of the given symbol.
def EPattern(rows, ch):
for i in range(rows):
print('%c' %ch, end='')
for j in range(rows):
if (i == 0 or i == rows - 1) or (i == rows // 2 and j <= rows // 2):
print('%c' %ch, end='')
else:
continue
print()
row = int(input("Enter Alphabet E of Stars Rows = "))
sy = input("Symbol for E Star Pattern = ")
EPattern(row, sy)
Enter Alphabet E of Stars Rows = 11
Symbol for E Star Pattern = #
############
#
#
#
#
#######
#
#
#
#
############