title: Error in writing to a file (Python)
body: <p>I made a program that outputs random binary characters. I wanted to modify it so it writes to a text file</p>
  
  <pre><code>print("Random Binary")
  import random
  file_ob = open('C:/Users/AV/Documents/Python/Binary.txt', 'w')
  count = int(input("Enter the number of characters needed: "))
  binary = [0]*8
  counter = 1
  while counter &lt;= count:
      cnum = 0
      while cnum &lt; 8:
              binary[cnum] = random.randint(0, 1)
              file_ob.write(print(str(binary[cnum]), end = ''))
              cnum += 1
      file_ob.write(print(end = ' '))
      counter += 1
  </code></pre>
  
  <p>But the IDLE gives me this error:   </p>
  
  <pre><code>Traceback (most recent call last):   
  File "C:/Users/AV/Documents/Python/Random Bin Write.py", line 11, in &lt;module&gt;   
  file_ob.write(print(str(binary[cnum]), end = ''))   
  TypeError: must be str, not None
  </code></pre>
  
  <p>I tried many things such as removing the <code>str</code>, removing <code>print</code> and a lot others, but it still gives me some error anyway... Please help.</p>