I need to write
ranks[a], ranks[b], count
to a file, each time on a new line
I am using:
file = open("matrix.txt", "w")
for (a, b), count in counts.iteritems():
file.write(ranks[a], ranks[b], count)
file.close()
but this is not working and returns
TypeError: function takes exactly 1 argument (3 given)
As the error says, file.write
only takes one arg. Try:
file.write("%s %s %s" % (ranks[a], ranks[b], count))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With