Throughout the book, we have mentioned several differences between Python 2 and Python 3. The book uses Python 2, but we also want you to know how to recognize Python 3 code and make your code compatible with Python 3 if you want to. This appendix only talks about the Python 2 to 3 differences in the parts of Python that we have covered in this book. (For example, Python 3 handles Unicode strings differently, but because we didn’t talk about Unicode, we won’t talk about the Python 3 Unicode changes.)
With that in mind, here are some of the ways Python 3 is different from Python 2.
In Python 3, print is a function. That means instead of writing
print "Hello, World!"
you need to write