Python Program to Print Hollow Rhombus Star Pattern

Write a Python Program to Print Hollow Rhombus Star Pattern using for loop. The nested for loop and if else statements help to print the hollow rhombus pattern.

# Python Program to Print Hollow Rhombus Star Pattern
 
hrows = int(input("Enter Howllow Rhombus Star Pattern rows = "))

print("Hollow Rhombus Star Pattern") 

for i in range(hrows, 0, -1):
    for j in range(1, i):
        print(' ', end = '')
    for k in range(0, hrows):
        if(i == 1 or i == hrows or k == 0 or k == hrows - 1):
            print('*', end = '')
        else:
            print(' ', end = '')
    print()
Python Program to Print Hollow Rhombus Star Pattern 1

This Python Program prints the Hollow Rhombus Star Pattern using a while loop.

# Python Program to Print Hollow Rhombus Star Pattern
 
hrows = int(input("Enter Howllow Rhombus Star Pattern rows = "))

print("Hollow Rhombus Star Pattern") 
i = hrows
while(i >= 1):
    j = 1
    while(j <= i - 1):
        print(' ', end = '')
        j = j + 1

    k = 1
    while(k <= hrows):
        if(i == 1 or i == hrows or k == 1 or k == hrows):
            print('*', end = '')
        else:
            print(' ', end = '')
        k = k + 1
    i = i - 1
    print()
Enter Howllow Rhombus Star Pattern rows = 15
Hollow Rhombus Star Pattern
              ***************
             *             *
            *             *
           *             *
          *             *
         *             *
        *             *
       *             *
      *             *
     *             *
    *             *
   *             *
  *             *
 *             *
***************
>>> 

In this Python example, we created a hollowRhombusStar function to print the Hollow Rhombus Pattern. It replaces the hollow Rhombus Patterns star with a given symbol.

# Python Program to Print Hollow Rhombus Star Pattern

def hollowRhombusStar(hrows, ch):
    for i in range(hrows, 0, -1):
        for j in range(1, i):
            print(' ', end = '')
        for k in range(0, hrows):
            if(i == 1 or i == hrows or k == 0 or k == hrows - 1):
                print('%c' %ch, end = '')
            else:
                print(' ', end = '')
        print()
    

hrows = int(input("Enter Howllow Rhombus Star Pattern hrows = "))
ch = input("Symbol to use in Howllow Rhombus Pattern = " )

print("Hollow Rhombus Star Pattern")
hollowRhombusStar(hrows, ch)
Enter Howllow Rhombus Star Pattern hrows = 18
Symbol to use in Howllow Rhombus Pattern = #
Hollow Rhombus Star Pattern
                 ##################
                #                #
               #                #
              #                #
             #                #
            #                #
           #                #
          #                #
         #                #
        #                #
       #                #
      #                #
     #                #
    #                #
   #                #
  #                #
 #                #
##################
>>>