Python Program to Print Hollow Right Pascals Star Triangle

Write a Python program to print hollow right pascals star triangle pattern using for loop. 

rows = int(input("Enter Hollow Right Pascals Star Triangle Pattern Rows = "))

print("====Hollow Right Pascals Star Triangle Pattern====")

for i in range(1, rows + 1):
    for j in range(1, i + 1):
        if j == 1 or j == i:
            print('*', end = '')
        else:
            print(end = ' ')      
    print()

for i in range(1, rows + 1):
    for j in range(rows - 1, i - 1, -1):
        if j == rows - 1 or j == i or i == rows:
            print('*', end = '')
        else:
            print(end = ' ')
    for k in range(1, i):
        print(end = ' ')
    print()
Python Program to Print Hollow Right Pascals Star Triangle

This Python program prints the hollow right pascals star triangle pattern using a while loop.

rows = int(input("Enter Hollow Right Pascals Star Triangle Pattern Rows = "))

print("====Hollow Right Pascals Star Triangle Pattern====")
i = 1

while(i <= rows):
    j = 1
    while(j <= i):
        if j == 1 or j == i:
            print('*', end = '')
        else:
            print(end = ' ')
        j = j + 1
    print()
    i = i + 1

i = 1
while(i <= rows - 1):
    j = rows - 1
    while(j >= i):
        if j == rows - 1 or j == i or i == rows:
            print('*', end = '')
        else:
            print(end = ' ')
        j = j - 1
    k = 1
    while(k < i):
        print(end = ' ')
        k = k + 1
    print()
    i = i + 1
Enter Hollow Right Pascals Star Triangle Pattern Rows = 8
====Hollow Right Pascals Star Triangle Pattern====
*
**
* *
*  *
*   *
*    *
*     *
*      *
*     *
*    * 
*   *  
*  *   
* *    
**     
*

In this Python example, we used the pyHollowRightPascalsStar function to display the hollow right pascals triangle pattern of a given character.

def pyHollowRightPascalStar(rows, ch):
    for i in range(1, rows + 1):
        for j in range(1, i + 1):
            if j == 1 or j == i:
                print('%c' %ch, end = '')
            else:
                print(end = ' ')      
        print()

    for i in range(1, rows + 1):
        for j in range(rows - 1, i - 1, -1):
            if j == rows - 1 or j == i or i == rows:
                print('%c' %ch, end = '')
            else:
                print(end = ' ')
        for k in range(1, i):
            print(end = ' ')
        print()

rows = int(input("Enter Hollow Right Pascals Star Triangle Pattern Rows = "))

ch = input("Symbol to use in Hollow Right Pascals Triangle Pattern = " )

print("====Hollow Right Pascals Star Triangle Pattern====")

pyHollowRightPascalStar(rows, ch)
Enter Hollow Right Pascals Star Triangle Pattern Rows = 10
Symbol to use in Hollow Right Pascals Triangle Pattern = #
====Hollow Right Pascals Star Triangle Pattern====
#
##
# #
#  #
#   #
#    #
#     #
#      #
#       #
#        #
#       #
#      # 
#     #  
#    #   
#   #    
#  #     
# #      
##       
#