Program to print x-cross pattern using python

QUESTION:

Write a python program to print  x-cross pattern using a stars

LOGIC:

  1. Get the length as an input from the user.
  2.  print the stars using condition
  3.  then print the corresponding spaces.

PROGRAM:

n=int(input("Enter the number:"))          //Get the input from the user
for i in range(0,n):                       
    for j in range(0,n):
        if(i==j or j==n-1-i):
            print("*",end=" ")             //print the stars
        else:
            print(" ",end=" ")             //corresponding spaces
    print()                                //next line

 

 

Follow For Instant Updates

Join WhatsApp Group: link
Join our Telegram Channel: link
Like our Facebook Page:  link
Subscribe to our Youtube channel: link

Sree Hari Sanjeev

The founder of Wisdom Overflow. Software Developer at Zoho Corporation.
0 0 votes
Article Rating
Subscribe
Notify of
guest
5.4K Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
5.4K
0
Would love your thoughts, please comment.x
()
x