In Python2, print was a keyword that stated a statement:
print "Hi"
In Python3, print is a function that can be called:
print ("Hi")
In both versions, % is an operator that requires a string on the left side and a value or tuple of values or a matching object (for example, dict ) on the right side.
So your line should look like this:
print("a=%d,b=%d" % (f(x,n),g(x,n)))
In addition, the recommendation for Python3 and new is to use {} -style formatting instead of % -line formatting:
print('a={:d}, b={:d}'.format(f(x,n),g(x,n)))
Robᵩ Oct 18 '13 at 19:04 on 2013-10-18 19:04
source share