Skip to Content
Hello World! Third Edition
book

Hello World! Third Edition

by Carter Sande, Warren Sande
December 2019
Beginner content levelBeginner
496 pages
15h 37m
English
Manning Publications
Content preview from Hello World! Third Edition

Appendix B. Differences Between Python 3 and 2

Throughout the book, we have mentioned several differences between Python 3 and Python 2. The book uses Python 3, but we also want you to know how to recognize Python 2 code and make your code compatible with Python 2 if you want to. This appendix only talks about the Python 3 to 2 differences in the parts of Python that we have covered in this book.

With that in mind, here are some of the ways Python 2 is different from Python 3.

print

In Python 2, print is a special “keyword” instead of a function. That means instead of writing

print("Hello, World!")

you can write:

print "Hello, World!"

There are some other differences related to this. Instead of using the end argument to make output from the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rotoscoping

Rotoscoping

Benjamin Bratt
Modern SVG

Modern SVG

Amelia Bellamy-Royds, Kurt Cagle
Wicked Cool Shell Scripts, 2nd Edition

Wicked Cool Shell Scripts, 2nd Edition

Dave Taylor, Brandon Perry

Publisher Resources

ISBN: 9781617297021Publisher SupportPublisher WebsiteSupplemental ContentErrata PagePurchase Link