header image
Click to view the other books
Automate the Boring Stuff with Python cover thumbnail Invent with Python cover thumbnail Making Games cover thumbnail Hacking Secret Ciphers cover thumbnail
Vote up on StumbleUpon.com

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

Chapter 4 - Guess the Number

The "Converting Strings to Integers with the int() Function" section has an example of the int() function which reads:

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
int('forty-two')
ValueError: invalid literal for int() with base
...when it should read int('hello') (Thanks to David Dantowitz)

42 != '42' evaluates to True, not False. (Thanks to Mohammad Ashrafuzzaman)

Chapter 5 - Jokes

The program is missing the escape backslash on line 5:

print('What do dentists call a astronaut\'s cavity?') (Thanks to Siddharth Bhatia)


  

Chapter 10 - Tic Tac Toe

The "The First if Statement (Cats and Dogs)" section has the line "on line 9 in our small program will first evaluate TrueFizz()", when it should be "on line 9 in our small program will first evaluate FalseFizz()". (Thanks to Ben White)

Short-Circuit Evaluation section has the line "The only times move not in '1 2 3 4 5 6 7 8 9'.split() evaluates to False are when move is not a single-digit string.". The second "not" should be removed to read: "The only times move not in '1 2 3 4 5 6 7 8 9'.split() evaluates to False are when move is a single-digit string." (Thanks to Sebastian Simon.)

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 "<stdin>", line 1, in <module>
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 13 - Sonar

Line 148 of the source code says The point where the device was dropped will be marked with a d. when it should say The point where the device was dropped will be marked with a 2. (Thanks to Sia Kia)

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)

Additional Typos

Thanks to Fran P. for this large collection of typos:

  • p.154: The gameIsPlayer variable keeps track of whether the game is still being played or if someone has won or tied." —> gameIsPlaying
  • p 170: This is much like how you'll get better at programming you more you keep at it. —> THE more you...
  • p 194: Line 69 returns False if the X and Y coordinates if was passed do not exist on the game board. —> IT was
  • p. 267: Line 275 # return corner move, or side move, or the best move —> here: only side or best move, not corner move
  • p.267: Line 296: "go through all the possible moves and remember the best scoring move" —> should be "worst" here, I think
  • p.268: line 310, a "space" —> I think it's either a corner move or the worst move
  • p 274: Chapters 17, 18 and 19 teaches you how to… —> teach
  • p.291: # check if the block has move out of the window —> moved
  • p 305: Line 11 never returns True, then none of the eight corner checked are in the other rectangle —> IF line 11...
  • p. 320: Copy the downloaded image file into the same folder as you Python program's .py file —> your