title: Python. How do i count the number of divisors in nested for loop?
body: <p>I have a code that generates triangular numbers, calculates the divisors for each triangular number and prints out 3 columns where the first column is the input numbers, the second column is the triangular numbers and the third column is the divisors of each triangular number. How can I count the number of divisors of each triangular number(count the numbers in the third column)?</p>
  
  <pre><code>for num in range(10):
      triangle_number = num*(num+1)//2
      print(num, end = '   ')
      print(triangle_number, end = '     ')
      for divisor in range(1, triangle_number+1):
          if triangle_number%divisor == 0:
              print(divisor,  end = ',')
      print()
  </code></pre>
  
  <p>Output looks like this:</p>
  
  <pre><code>0   0     
  1   1     1,
  2   3     1,3,
  3   6     1,2,3,6,
  4   10     1,2,5,10,
  5   15     1,3,5,15,
  6   21     1,3,7,21,
  7   28     1,2,4,7,14,28,
  8   36     1,2,3,4,6,9,12,18,36,
  9   45     1,3,5,9,15,45,
  
  </code></pre>