Python Forum

Full Version: SyntaxError
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I'm getting a syntax error on the print to file. Can someone correct me please?

Error:
C:\Python27\python.exe C:/Users/David/PycharmProjects/pythonProject2/venv/init_collapse.py File "C:/Users/David/PycharmProjects/pythonProject2/venv/init_collapse.py", line 236 print("%.8f" % (kxx[0, ii]), file=output) ^ SyntaxError: invalid syntax Process finished with exit code 1
with open(file_ls, "w") as output:
    output.write("%d %d %d" % (np.shape(kxx)[1], np.shape(kxx)[0], collapse_steps,))
    for ii in np.arange((np.shape(kxx)[1])):
        print("%.8f" % (kxx[0, ii]), file=output)
You are writing code using some syntax that is from python3, but trying to run it with a python2 executable. The code is syntactically correct for python3.
Thank you