Click to view the other books

If you find any typos, please email them to al@inventwithpython.com. (Apologies in advance if I haven't posted your errata submission yet or failed to give credit. Please email me to correct this.)

Chapter 11 - Bagels

The "The sort() List Method" section has this example:

>>> spam = [5, 'bat', 3, 1, 4, 'cat', 2, 'ape']
>>> spam.sort()
>>> spam
[1, 2, 3, 4, 5, 'ape', 'bat', 'cat']
While this code works in Python 2, it won't work in Python 3 because it gives this error:
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unorderable types: str() < int()
The reason is because in Python 3 the integer and string values are not automatically comparable to each other. You would need to run this line of code: spam.sort(key=str) which would pass all the values (such as the 5, 3, 1, 4, and 2 integer values) to the str() function first and then use the return value for sorting comparison.

This code was left over from the first edition of the book that used Python 2. (Thanks to "Team Liquid")

Chapter 17 - Graphics and Animation

On page 336, there is the text "If you forget to delete the Surface object" which should be "If you forget to delete the PixelArray object". (Thanks to Jerry Zhao)