I downloaded and installed Python 3.1.2 on Windows 7 x64. But it seems that it's not working as expected, for example:
Please help me figure out, what's wrong here?
I downloaded and installed Python 3.1.2 on Windows 7 x64. But it seems that it's not working as expected, for example:
Please help me figure out, what's wrong here?
Try this:
>>> print "Today's stock price: %f" % 50.4625
File "<stdin>", line 1
print "Today's stock price: %f" % 50.4625
^
SyntaxError: invalid syntax
>>> print("Today's stock price: %f" % 50.4625)
Today's stock price: 50.462500
Python 3.X changed how print works, and now requires parentheses around the arguments.
Python 3.X is not backward-compatible with Python 2.X. Make sure you are reading a 3.X tutorial, or remove 3.X and install 2.X.
Here's some reading about why there are differences and to decide which to use: http://wiki.python.org/moin/Python2orPython3.
As stated above python 3.x now requires all statements such as those to be function calls, Python 3.x is supposed to bring back the functional aspect of C to python although code that works in 3.x will most likely work in 2.x but not necessarily the other way around.