Python Program to Print Sandglass Alphabets Pattern
This Python program prints a sandglass pattern using alphabets. The pattern starts with the given alphabet and decreases till it reaches ‘A’, then increases again to form a sandglass pattern.
def sandglass_pattern(alphabet):
for i in range(ord(alphabet), ord('A') - 1, -1):
for j in range(ord('A'), i + 1):
print(chr(j), end=' ')
print()
for i in range(ord('B'), ord(alphabet) + 1):
for j in range(ord('A'), i + 1):
print(chr(j), end=' ')
print()
alphabet = 'E'
sandglass_pattern(alphabet)
Copy and paste the above Python program in your code editor to see the sandglass alphabets pattern printed on your screen.
Feel free to customize the starting alphabet in the alphabet
variable to create different sandglass patterns.