from this post, I've been using the following code to write a list/array to a file:
with open ("newhosts.txt",'w') as thefile:
for item in hostnameIP:
thefile.write("%s\n" % item)
where hostnameIP
is:
[['localhost', '::1'], ['localhost', '::1'], ['localhost', '::1']]
In the file, I get the output:
['localhost', '::1']
['localhost', '::1']
['localhost', '::1']
when I need to to say
localhost, ::1
localhost, ::1
localhost, ::1
What would be the best way to do this?