Q. Write a program to print the following pattern :-


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


Answer =
for i in range (8):
    for j in range(8):
        if i==0 or i==7:
            print("*",end=" " )
        elif j==8-(1+i):
            print("*",end=" " )
        else:
            print(" ",end=" " )
    print()

6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Not got the required output!!

    ReplyDelete
    Replies
    1. Copy the whole program as it is .

      Delete
    2. The correct code should be:
      for i in range (8):
      for j in range(8):
      if i==0 or i==7:
      print("*",end=" " )
      elif j==8-(1+i):
      print("*",end=" " )
      else:
      print(" ",end=" " )
      print()

      Delete
  2. The code given by you is not yeilding proper required output , i have corrected the code so please update it. Thank me later.
    Code-
    for i in range (8):
    for j in range(8):
    if i==0 or i==7:
    print("*",end=" " )
    elif j==8-(1+i):
    print("*",end=" " )
    else:
    print(" ",end=" " )
    print()

    ReplyDelete
    Replies
    1. Kindly check the indentation level yourself as it is not allowing spaces

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post