Write a Python Program to Print the Left Arrow Star Pattern using a for loop, while loop, and functions. This example uses the nested for loop to iterate and print the Left Arrow Star Pattern.
rows = int(input("Enter Left Arrow Pattern Rows = "))
print("====The Left Arrow Pattern====")
for i in range(1, rows + 1):
for j in range(1, rows - i + 1):
print(' ', end = '')
for k in range(i, rows + 1):
print('*', end = '')
print()
for i in range(1, rows):
for j in range(i):
print(' ', end = '')
for k in range(i + 1):
print('*', end = '')
print()
Output.

This Python program replaces the above for loop with a while loop to print the Left Arrow Star Pattern.
rows = int(input("Enter Left Arrow Pattern Rows = "))
print("====The Left Arrow Pattern====")
i = 1
while i <= rows:
j = 1
while j <= rows - i:
print(' ', end = '')
j = j + 1
k = i
while k <= rows:
print('*', end = '')
k = k + 1
i = i + 1
print()
i = 1
while i < rows:
j = 0
while j < i:
print(' ', end = '')
j = j + 1
k = 0
while k <= i:
print('*', end = '')
k = k + 1
i = i + 1
print()
Output
Enter Left Arrow Pattern Rows = 8
====The Left Arrow Pattern====
********
*******
******
*****
****
***
**
*
**
***
****
*****
******
*******
********
In this Python example, we created a LeftArrow function that accepts the rows, i value, and characters to Print the Left Arrow Star Pattern. It replaces the star in the left arrow pattern with a given symbol.
def LeftArrow(rows, ch):
for i in range(1, rows + 1):
for j in range(1, rows - i + 1):
print(' ', end = '')
for k in range(i, rows + 1):
print('%c' %ch, end = '')
print()
for i in range(1, rows):
for j in range(i):
print(' ', end = '')
for k in range(i + 1):
print('%c' %ch, end = '')
print()
rows = int(input("Enter Left Arrow Pattern Rows = "))
ch = input("Symbol in Left Arrow Pattern = ")
print("====The Left Arrow Pattern====")
LeftArrow(rows, ch)
Output
Enter Left Arrow Pattern Rows = 7
Symbol in Left Arrow Pattern = $
====The Left Arrow Pattern====
$$$$$$$
$$$$$$
$$$$$
$$$$
$$$
$$
$
$$
$$$
$$$$
$$$$$
$$$$$$
$$$$$$$