This article shows how to write a Python program to print the Alphabet T star pattern using the for loop, while loop, and functions with an example.
The below alphabet T 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 row and the middle column to get the Alphabetical T pattern of stars and skip others.
rows = int(input("Enter Alphabet T of Stars Rows = "))
print("====The Alphabet T Star Pattern====")
for i in range(rows):
for j in range(rows):
if i == 0 or j == rows // 2:
print("*", end=" ")
else:
print(" ",end=" ")
print()

Python program to print the Alphabet T Star pattern using while loop
Instead of a For loop, this program uses the while loop to iterate the Alphabet T pattern rows and prints the stars on the first row and middle column. For more Star Pattern programs >> Click Here.
rows = int(input("Enter Alphabet T of Stars Rows = "))
i = 0
while i < rows:
j = 0
while j < rows:
if i == 0 or j == rows // 2:
print("*", end=" ")
else:
print(" ",end=" ")
j += 1
print()
i += 1
Enter Alphabet T of Stars Rows = 11
* * * * * * * * * * *
*
*
*
*
*
*
*
*
*
*
In this Python example, we created a TPattern function that accepts the rows and the symbol or character. Next, it prints the Alphabet T pattern of the given symbol.
def TPattern(rows, ch):
for i in range(rows):
for j in range(rows):
if i == 0 or j == rows // 2:
print('%c' %ch, end=' ')
else:
print(" ", end=" ")
print()
row = int(input("Enter Rows = "))
sy = input("Symbol for T Star Pattern = ")
TPattern(row, sy)
Enter Rows = 13
Symbol for T Star Pattern = $
$ $ $ $ $ $ $ $ $ $ $ $ $
$
$
$
$
$
$
$
$
$
$
$
$