fork download
  1.  
  2. h=int(input("Enter the height of the diamond : "))
  3.  
  4. if(h%2==0):
  5. h=h+1
  6. sp1=(h//2)-1
  7.  
  8. else:
  9. sp1=(h//2)
  10.  
  11. sp2=-1
  12.  
  13. for i in range(1,h+1,1):
  14.  
  15.  
  16. for k in range(1,sp1+1,1):
  17. print(" ",end="")
  18.  
  19.  
  20.  
  21. print("*",end="")
  22.  
  23.  
  24. for k in range(1,sp2+1,1):
  25. print(" ",end="")
  26.  
  27.  
  28. if(i!=1 and i!=h):
  29. print("*",end="")
  30.  
  31.  
  32.  
  33. print("\n")
  34.  
  35.  
  36. if(i<(h//2)+1):
  37. sp1=sp1-1
  38. sp2=sp2+2
  39.  
  40. else:
  41. sp1=sp1+1
  42. sp2=sp2-2
  43.  
  44.  
  45.  
Success #stdin #stdout 0.03s 9240KB
stdin
45
stdout
Enter the height of the diamond :                       *

                     * *

                    *   *

                   *     *

                  *       *

                 *         *

                *           *

               *             *

              *               *

             *                 *

            *                   *

           *                     *

          *                       *

         *                         *

        *                           *

       *                             *

      *                               *

     *                                 *

    *                                   *

   *                                     *

  *                                       *

 *                                         *

*                                           *

 *                                         *

  *                                       *

   *                                     *

    *                                   *

     *                                 *

      *                               *

       *                             *

        *                           *

         *                         *

          *                       *

           *                     *

            *                   *

             *                 *

              *               *

               *             *

                *           *

                 *         *

                  *       *

                   *     *

                    *   *

                     * *

                      *