Python Program to Print Hollow Square Pattern with Diagonal of Stars using loops
Python program to print hollow square pattern with diagonal of stars using loops (for and while loop).
In this program, you will learn how to print a hollow square star pattern with diagonal using loops.
Take an example to print this pattern through a python program:
# Python Program to Print Hollow Square Pattern with Diagonal of Stars using loops print ("-----Enter the side of a square-----") sS = int (input ()) print (end="\n") for x in range (1, sS + 1): for y in range (1, sS + 1): # It will check boundary conditions # It will check diagonal and secondary diagonal conditions if (x == 1) or (x == sS) or (y == 1) or (y == sS) or (x == y) or (y == (sS - x + 1)): print (end="*") else: print (end=" ") print (end="\n")