Python Star Pattern Program 2

By | July 23, 2019

Python Star Pattern Program 2 – This Python Programming Tutorial explains the nested for loop logic to display a star pattern # 2 as shown below:

*****
****
***
**
*
Python Star Pattern Program 2

Python Star Pattern Program 2


The source code of Python Star Pattern Program 2

# Write a program to display
# the following star pattern
# using for loops
#  *****
#  ****
#  ***
#  **
#  *

# Author: www.EasyCodeBook.com (c)

lines = int(input('How many star line in Star Pattern?:'))
print('The required star pattern is:')
for i in range(lines,0,-1):
    for j in range(1,i+1):
        print('*', end='')
    print()

The output of star patterns 2

How many star line in Star Pattern?:5
The required star pattern is:
*****
****
***
**
*

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *