print (n+1) ": x1= ",x1,"f(x)= ",fx
I want it to print what the x1 is and the value of the function at x1 (fx), but I get an invalid syntax on the end of the first quotation. Can someone explain to me what my problem is.
这是你想要做的(假设所有都是整数):
print("%d: x1= %d f(x)=%d" % ((n+1),x1,fx))
你在n + 1之后错过了一个逗号
print (n+1), " : x1=",x1,"f(x)=",fx
The problems are
There should be a comma(,) before the 1st quotation.
print (n+1), " : x1=",x1,"f(x)=",fx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.