Sandglass Star in Python

Problem Statement:

The problem statement is straightforward, we need to print a sandglass pattern using ‘*‘. We are given an integer and we need to write code in Python that can print a sandglass star pattern. Check the image below to know what a sandglass pattern looks like:

Sandglass Star pattern example

Code to print sandglass star in Python:

n = int(input('Enter value of n: '))
for i in range(n):
    print(' '*(i), end='')
    print(' *'*(n-i), end='')
    print()
for i in range(2, n+1):
    print(' '*(n-i), end='')
    print(' *'*(i), end='')
    print()

Output:

Output for Sandglass Star in Python

Also Read:

Share:

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@violet-cat-415996.hostingersite.com Thank you