title: 2D grid using for loop in Python
body: <p>I want to create a 2D grid with for loop in python. I can do simple code like this:</p>
  
  <pre><code>cols = 10
  rows = 10
  grid = [[0 for x in range(cols)] for y in range(rows)]
  print(grid)
  </code></pre>
  
  <p>But when I try to loop through i in rows and then j in columns, it shows error: list index out of range. Not sure where went wrong with my coding?</p>
  
  <pre><code>rows = 10
  cols = 10
  i = 0
  for i in range(rows):
      for j in range(cols):
          grid[i].append([j])
          i += 1
  </code></pre>