title: Difficulty understanding nested loops with addition, range and print function
body: <p>When I put this python code with input 12, the answer is 0, 6, 18. I dont know how to calculate that and I keep visualizing it as code snippet 2, with the answers 0,0,1,3,6,6,8,12.</p>
  <p>How does this loop work?</p>
  <pre><code>stop=int(input())
  result=0
  for a in range(5): 
    for b in range(4): 
      result += a * b
    print(result)
    if result &gt; stop: 
      break 
  </code></pre>
  <p>What I calculate</p>
  <pre><code>stop=int(input())
  result=0
  for a in range(5): 
    for b in range(4): 
      result += a * b
      print(result)
    if result &gt; stop: 
      break 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/uLg2c.png" rel="nofollow noreferrer">picture of my calculations</a></p>