title: How to fix TypeError: "NoneType" is not iterable?
body: <p>I'm making a program that is meant to go through all four digit numbers and order their digits in ascending order to create another number, and then all of them in descending order. Substracting these should give another <code>4</code> digit number. Repeating this process a few times eventually gives a resulting number of <code>6174</code>. I want my program to test this for all <code>4</code> digit numbers.</p>
  
  <p>I've tried <code>[str(i) for i in bigdigits]</code> and other lines in the Python Console and it worked out fine. But I can't get it to work in the actual program.</p>
  
  <p>I tried debugging this to no result. As well as printing out all partial results for variables. The result of printing all of the lists is None.</p>
  
  <pre><code>counter = 1000
  while counter != 10000:
      digits = [int(x) for x in str(counter)]
      bigdigits = digits.sort(reverse = True)
      smalldigits = digits.sort()
  
      strbigdigs = [str(i) for i in bigdigits]
      bignum = int("".join(strbigdigs))
  
      strsmalldigs = [str(j) for j in smalldigits]
      smallnum = int("".join(smalldigits))
  
      partialanswer = bignum - smallnum
      print(partialanswer)
  </code></pre>
  
  <p>For example, if counter were <code>2019</code>, digits should be <code>[2, 0, 1, 9]</code> and bigdigits would be <code>[9, 2, 1, 0]</code>. Then strbigdigs would be <code>['9', '2', '1', '0']</code>. Finally, bignum would be <code>9210</code>.</p>