擅长:python、mysql、java
<p>从概念上讲,while循环与for循环完全相同,只是没有增量。因此,如果需要使用while实现循环,只需按照for循环的方式执行,但要自己递增。所以这意味着你只需要嵌套两个whiles:</p>
<pre><code>x = 0
table = ''
while x < WIDTH:
y = 0
while y < LENGTH:
table += grid[WIDTH * x + y] + '|'
y +=1
table += '\n'
x +=1
return table
</code></pre>