Hollow diamond in python with an asterisk outline
<p>I have to build a hollow diamond like this one:</p>

<pre><code>   ******
   **  **
   *    *
   *    *
   **  **
   ******
</code></pre>

<p>Heres what I have so far, </p>

<pre><code>def hollow_diamond(w):
 h=int(w/2)
 while 0&lt;h:
  print('*'*h)
  h=h-1
 i=1
 while i&lt;(w/2+1):
  print(i*'*')
  i=i+1
</code></pre>

<p>However using the code that i have i only get half of the diamond.</p>

<pre><code>***
**
*
*
**
***
</code></pre>

<p>Should I be using <strong>for</strong> loops instead of while to be able to complete the diamond?</p>

<p>I won't steal from you the joy to fix your homework but this exercise was quite fun so I'll give you another possible version to give you few ideas:</p>

<pre><code>def cool_diamond(w):
    r = []
    for y in range(w):
        s = '*' * (w - y)
        r.append("{0}{1}{0}".format(s, ''.join(['-' for x in range(2 * y)]), s))

    return '\n'.join(r + r[::-1])

for i in range(3, 6):
    print cool_diamond(i)
    print('-' * 80)
</code></pre>

<p>I'd strongly recommend you take your time first to fix yours! Otherwise you won't learn nothing from the exercise. </p>

<p>Once you've fixed yours you'll feel pretty satisfied for the effort paying off, and then... just then, you can take think whether you can improve YOUR version or refactoring.</p>

<p>Happy coding!</p>

<pre><code>******
**--**
*----*
*----*
**--**
******
--------------------------------------------------------------------------------
********
***--***
**----**
*------*
*------*
**----**
***--***
********
--------------------------------------------------------------------------------
**********
****--****
***----***
**------**
*--------*
*--------*
**------**
***----***
****--****
**********
--------------------------------------------------------------------------------
</code></pre>

python python-3.x