Okay, I have a program that outputs tuples containing integers and appends them to a list like this:
[(0,98,7), (437, 563, 128), (82, 45, 221)...]
I'm wanting to write the tuples to a file with the .write() function like this with "values" as the list the tuples are stored in:
output=open("output.txt","w")
for v in range(len(values)):
print(values[v]) #so it prints each value in the shell for error check
output.write(values[v])
The expected result is a text file with its contents like this:
0,98,7
437, 563, 128
82, 45, 221
...
The problem is that it says it can't write a tuple to a file; it asks for a string. I've tried to use the .join() function and the list() function to try to change the tuple either to a string or a list within the values list. Does anyone know how I could solve this issue? Thanks so much.