Pages

Wednesday, 20 January 2016

Diamond OF Asterick '*'

# To print a diamond of Asterick '*'
# Set your font type As Courier
n=int(raw_input("Enter a no."))
n=(n-1)/2
w=n
x=1
for i in range(n) :
    for j in range(w,0,-1) :
        print " ",
    w=w-1
    for k in range(-1,i*2) :
        print "*",
    print
for i in range(n,-1,-1) :
    for j in range(0,w) :
        print " ",
    w=w+1
    for k in range(i*2-1,-2,-1) :
        print "*",
    print

Output
Enter a no. 9
        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *
  * * * * * * *
    * * * * *
      * * *
        *