I am trying to write A in multiple folders, namely, 1,2,3,4,5 with file name A.txt. But I am getting an error. How do I fix it?
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"A.txt"), 'w+') as f:
#print("A =",[A])
writer = csv.writer(f)
writer.writerow(A)
for x in range(Runs):
function(x)
The error is
in function
writer.writerow(A)
Error: iterable expected, not int
print("A =",[A])is a subtle lie to yourself. You're printing[A]as a list, but using it as a scalar. The error tells you everything you need to know