Python Program to Print Sandglass Alphabets Pattern

Write a Python program to print sandglass alphabets pattern using for loop.

rows = int(input("Enter Sandglass Alphabets Pattern Rows = "))

print("====The Sandglass of Alphabets Pattern====")
alphabet = 64

for i in range(1, rows + 1):
    for j in range(1, i):
        print(end = ' ')
    for k in range(i, rows + 1):
        print('%c' %(alphabet + k), end = ' ')
    print()

for i in range(rows - 1, 0, -1):
    for j in range(1, i):
        print(end = ' ')
    for k in range(i, rows + 1):
        print('%c' %(alphabet + k), end = ' ')
    print()
Python Program to Print Sandglass Alphabets Pattern

This Python program displays the sandglass pattern of alphabets using a while loop.

rows = int(input("Enter Sandglass Alphabets Pattern Rows = "))

print("====The Sandglass of Alphabets Pattern====")
alphabet = 64
i = 1

while(i <= rows):
    j = 1
    while(j < i):
        print(end = ' ')
        j = j + 1
    k = i
    while(k <= rows):
        print('%c' %(alphabet + k), end = ' ')
        k = k + 1
    print()
    i = i + 1

i = rows - 1
while(i >= 1):
    j = 1
    while(j < i):
        print(end = ' ')
        j = j + 1
    k = i
    while(k <= rows):
        print('%c' %(alphabet + k), end = ' ')
        k = k + 1
    print()
    i = i - 1
Enter Sandglass Alphabets Pattern Rows = 11
====The Sandglass of Alphabets Pattern====
A B C D E F G H I J K 
 B C D E F G H I J K 
  C D E F G H I J K 
   D E F G H I J K 
    E F G H I J K 
     F G H I J K 
      G H I J K 
       H I J K 
        I J K 
         J K 
          K 
         J K 
        I J K 
       H I J K 
      G H I J K 
     F G H I J K 
    E F G H I J K 
   D E F G H I J K 
  C D E F G H I J K 
 B C D E F G H I J K 
A B C D E F G H I J K 

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.