set1 = [(1,21,0),(1,20,0),(1,19,0),(1,18,0),(1,17,0)]
set2 = [(2,21,0),(2,20,0),(2,19,0),(2,18,0),(2,17,0),(2,16,0),(2,15,0)]
setNumber = [1,2]
for num in setNumber:
test = 'set'+str(num)
for (a,b,c) in test:
with open('test'+str(num)+'.csv','a') as f:
writer = csv.writer(f)
row_data = [a,b,c]
writer.writerow(row_data)
f.close
I have two list of tuples of numbers and I want to create a loop that can go through each list but I can't make 'test' as a "range variable".
if test = set1 or test = set2, no issue, files are created.
Thanks for the help.