HTML & JS
print("Give the height of diamond:")
n=int(input())
for i in range(1,n+1):
    for j in range(1,i+1):
        if i==j or j==1:
            print("*",end=" ")
        else:
            print(" ",end=" ")
    print()
for i in range(n-1,0,-1):
    for j in range(1,i+1):
        if i==j or j==1:
            print("*",end=" ")
        else:
            print(" ",end=" ")
    print()

Generated URL:

Output:

Give the height of diamond:
* 
* * 
*   * 
*     * 
*       * 
*         * 
*           * 
*             * 
*               * 
*             * 
*           * 
*         * 
*       * 
*     * 
*   * 
* * 
* 
Report Bug