title: How does this code work? What tells it to stop printing after the third row? Can someone break it down for me, in the most dumbed down way possible?
body: <pre><code>import random
  
  def main():
      printMatrix(3)
  </code></pre>
  
  <h1>i don't understand how this code stops after the third row</h1>
  
  <pre><code>def printMatrix(n):
      for i in range(1, n + 1):
          for j in range(1, n + 1):
              print(random.randint(0, 1), end = " ")
  
          print()
  
  main()
  </code></pre>