I have two lists results
, xvariables
and I want to write them out, side by side, on a file results.txt
.
According to this question, the best way to achieve a side by side lists writing is this:
f = open("results.txt", "w")
for idx, vals in zip(results, xvariables):
print idx
print ('---'.join(vals))
However, i am getting this error:
print ('---'.join(vals))
TypeError
Additionally i need to pair each item of the first list (results
) with three items of the second one (xvariables
).
The abovementioned lists are like that:
results
-----> [20.354999999999997, 20.354999999999997]
xvariables
--> [2, 3, 4, 2, 3, 4]
So i need 2,3,4
to be written side by side with 20.354999999999997
and so on.
How am I supposed to achieve this?