title: Automatically generate list from math function?
body: <p>My idea is to run the 3n + 1 process (<a href="https://en.wikipedia.org/wiki/Collatz_conjecture" rel="nofollow noreferrer">Collatz conjecture</a>) on numbers ending in 1, 3, 7, and 9, within any arbitrary range, and to tell the code to send the lengths of each action to a list, so I can run functions on that list separately.</p>
  
  <p>What I have so far is to specify unit digits 1,3,7 and 9 as: <code>if n % 10 == 1</code>; <code>if n % 10 == 3</code> ...etc, and I think my plan needs some form of nested for loops; where I'm at with list appending is to have <code>temp = []</code> and <code>leng = []</code> and find a way for the code to automatically <code>temp.clear()</code> before each input to <code>leng</code>. I'm assuming there's different ways to do this, and I'm open to any ideas.</p>
  
  <pre><code>leng = []
  temp = []
  def col(n):
      while n != 1:
          print(n)
          temp.append(n)
          if n % 2 == 0:
              n = n // 2
          else:
              n = n * 3 + 1
      temp.append(n)
      print(n)
  </code></pre>