What is the correct format to write float value to file in Python

the way you are writing to the file looks like you are giving two arguments to write function. So you need to only pass one argument. try converting x1 and x2 into string and then write to the file.

f.write("This is x1 " + str(x1))
f.write("This is x2 " + str(x2))

Leave a Comment