title: Python: Using two while loops to create grid. No for loops
body: <p>I'm having trouble trying to get my while loop to keep looping until both conditions are met. I'm only supposed to use while loops or if-statements/booleans if necessary.</p>
  
  <p>I'm trying to print the grid for a game of grid size LENGTH X WIDTH.
  So suppose </p>
  
  <pre><code>LENGTH = 5
  WIDTH = 6
  
  def create_grid(grid):
  
      x = 0
      y = 0
  
      while x &lt; WIDTH and y &lt; LENGTH:
            table = print(grid[WIDTH * x + y] + '|')
            x +=1
            y +=1
  
      return table
  </code></pre>
  
  <p>How do I get the while loop to loop for both x +=1 and y +=1 for the expression above?
  I'd want it so that it would print this expression</p>
  
  <pre><code>while y &lt; LENGTH:
      print('|' + grid[(0) * WIDTH + y] + '|' + '|' + grid[(1) * WIDTH + y] + ...
      + '|' + grid[(all the way up to WIDTH - 1) * WIDTH + y] + '|')
  
      y += 1
  
  return ###expression above
  </code></pre>
  
  <p>I put in brackets where I'd like to substitute the numbers for x, x+1,...all the way up to x = WIDTH - 1 (or x &lt; WIDTH).</p>
  
  <p>I suppose I could just concatenate the pieces like this, and use just one while loop like above, but say the grid dimensions were huge, writing out the whole grid would take up too much space.</p>