title: Writing data to multiple folders in Python
body: <p>I am trying to write <code>A</code> in multiple folders, namely, <code>1,2,3,4,5</code> with file name <code>A.txt</code>. But I am getting an error. How do I fix it?</p>
  <pre><code>import os
  
  Runs=5
  
  def function(run):
      from scipy.stats import truncnorm
      import numpy as np
      import csv 
      
      parent_folder = str(run + 1)
      os.mkdir(parent_folder)
  
      A=3
  
  
      ######################################
  
      with open(os.path.join(parent_folder, rf&quot;A.txt&quot;), 'w+') as f: 
          
          #print(&quot;A =&quot;,[A])
          writer = csv.writer(f)
          writer.writerow(A)
       
  
  
  for x in range(Runs):
      function(x)
  
  </code></pre>
  <p>The error is</p>
  <pre><code>in function
      writer.writerow(A)
  
  Error: iterable expected, not int
  </code></pre>