Aide in modifying this code removing the ' * ' operator and using while loops instead?
<p>How can I modify my code and remove the ' * ' operator which I have used to multiply strings and use while loops instead of it to produce the same pattern?</p>

<pre><code>i = 1
x = 1
while i &lt;= 4:
    print "v"*x
    print "v"*x
    x = x+1
    i+=1
print "v"*5
b = 4
while b&gt;=1:
    print "v"*b
    print "v"*b
    b=b-1
</code></pre>

<p>Hey this is the simplest way of doing this.</p>

<pre><code>length = 4
i = 0
output = "v"
for j in range(length-1):
    print output + "\n" + output
    output += "v"
print output
for j in range(length):
    output = output[:-1]
    print output + "\n" + output
</code></pre>

<p>Try this out. Hope this helps.</p>

<p>If want to use only while loop..here's the solution.</p>

<pre><code>length = 4
i = 1
output = "v"
flag = False
while (i &lt; length):
    if i == 0:
        break
    if not flag:
        print output + "\n" + output
        output += "v"
        i+=1
    else:
        output = output[:-1]
        print output + "\n" + output
        i-=1
    if i == length:
        i-=1
        print output
        flag = True
</code></pre>

<p>Hope this solves for query. :)</p>

python python-2.7 while-loop