Python Program to Print Hollow Box Pattern of Numbers
This program will print a hollow box pattern of numbers using Python.
# Python program to print hollow box pattern of numbers
def print_hollow_box_pattern(n):
for i in range(1, n+1):
for j in range(1, n+1):
if i == 1 or i == n or j == 1 or j == n:
print(j, end=" ")
else:
print(" ", end=" ")
print()
n = 5
print_hollow_box_pattern(n)
Copy and paste the code into your Python IDE and run the program to see the hollow box pattern of numbers.
Make sure to adjust the value of `n` to change the size of the box pattern.
Don’t forget to like, share, and subscribe for more Python programming tutorials!