Python Program to Print (Generate) Plus Star Pattern

This program prints Plus like pattern made of star in Python programming language.

To generate plus pattern we first read value of n from user. After reading n we generate plus pattern having n stars on each segment in the pattern.

Python Source Code: Plus Pattern


# Creating plus pattern of stars

# Reading the value of n
n = int(input('Enter value of n: '))

for i in range(1,2*n):
    for j in range(1,2*n):
        if i==n or j==n:
            print('*', end='')
        else:
            print(' ', end='')
    print()

Output: Plus Pattern

Output of generated plus pattern is:

Enter value of n: 10

         *         
         *         
         *         
         *         
         *         
         *         
         *         
         *         
         *         
*******************
         *         
         *         
         *         
         *         
         *         
         *         
         *         
         *         
         *