We try to keep our books accurate, but sometimes mistakes creep in. This page lists the errors submitted by our astute readers. If you've found a new error, please submit it.

The latest version of the book is P1.0, released 10 months ago. If you've bought a PDF of the book and would like to upgrade it to this version (for free), visit your home page.

Key: Typo Tech. Error Suggestion Not a problem Next edition

By default this page displays the errata for the latest version of the book. If you have a previous version, select it here:  

(To find out what version you have, look at the copyright page, a few pages in from the front of the book. If it says (say) 'Second Printing', then here it'll be P2.0. If there are interim PDF releases in that printing, they'll be 2.1, 2.2, and so on.)

PDF Paper Description Found in Fixed in
1

#76854: Would it be possible or desirable to provide the Exercise Solutions in a PDF or some other easily printable form? --David @ Support

P1.0
10-Jun-14
11
#52431: "For the mathematically inclined, the relationship between // and % comes from this equation, for any two numbers a and b: (b * (a // b) + a ...more...
B8.0
21-Aug-13
12
#53034: The operator ** for type is not listed under section 2.3. Instead the operator * is listed twice. Wrong: "these operators can be applied to t...more...
P1.0
17-Oct-13
28
#52586: Fourth bullet point - It may be helpful to clarify the second sentence by explaining that the variable will now point to the new value. I fin...more...
B8.0
05-Sep-13
28 28

#52594: "Variables must be assigned values before they can used in expressions." the word "be" is missing

B8.0
08-Sep-13
32

#52591: "...refers to 10, Python
Python evaluates this expression to -7."

Duplication of the word Python--Dave Pelter

B8.0
07-Sep-13
32

#52428: end of line 5, beginning of line 6: the word Python is repeated.

B8.0
20-Aug-13
51
#52449: There are 2 instances where the text in step "4. Description" doesn't match the text in step "5. Body". First, the latter ends with "which are...more...
B8.0
24-Aug-13
57
#53108: "2. Type Contract. The arguments in our function call examples are all inte- gers, and the return values are integers too," The return valu...more...
P1.0
02-Nov-13
59

#53354: The first code example of section 3.7 reads:

>>> 3 + 5 / abs(-2)
5.5

When I type this into IDLE 3, the return value is 4.0, not 5.5.--Ben

P1.0
15-Dec-13
62
#52377: Introduction of "!=" in example: Precondition: n != 0 Not is Index as symbol. Indexed as "Not operator". Defined in text at page 84. ...more...
B8.0
13-Aug-13
65
#52968: Nowhere in the description of strings is it mentioned that a string is a list of characters and that each character can be accessed by its ind...more...
P1.0
22-Sep-13
70

#52441: line 4 of the text reads: "using the *operator" -- there should be a space after the "*".

B8.0
23-Aug-13
71

#52442: Lines 4 and 5 explain that single quotes can be used for strings containing double quotes. Then lines 6 and 7 repeat that.

B8.0
23-Aug-13
72

#52443: Line 10 of the text contains: "Python creates contains a \n sequence" which should read "Python creates contains a \n escape sequence".

B8.0
23-Aug-13
76
#52445: Line 1 of the text starts: "In an earlier chapter, we explored some built-in functions." For clarity should read "In chapter 3, we explored so...more...
B8.0
23-Aug-13
81

#76968: "Return True iff x is positive." - note extra 'f' in 'if'.--Paul Golds

P1.0
08-Jul-14
85

#52451: In the example at the bottom of the page the 5th to last line reads: "Return True iff x is positive." This should be "Return True if x is positive."

B8.0
25-Aug-13
85
#76269: The sentence 'This is often referred to as or Python decides which string is greater than which by comparing corresponding characters from lef...more...
P1.0
07-Jan-14
88

#76270: In the final example shouldn't there be parentheses around the string to be printed?

P1.0
07-Jan-14
89
#52568: Comparing Strings. The characters in strings are represented by integers: a capital A, for example, is represented by 65, while a space is 32...more...
B8.0
03-Sep-13
90
#52488: The section describing the IN operator uses an example meant to illustrate the case sensitivity of the operator. However the example is wrong:...more...
B8.0
28-Aug-13
90
#52554: About mid-page, example reports that the phrase, or whatever I should call it, 'A' in 'abc' is True. This violates the case sensitivity of thi...more...
B8.0
01-Sep-13
90

#52560: as printed:

>>> 'A' in 'abc'
True

should be:

>>> 'A' in 'abc'
False

B8.0
02-Sep-13
90

#52589: [...] This is case sensitive:

is:
>>> 'A' in 'abc'
True

should be:
>>> 'A' in 'abc'
False

B8.0
06-Sep-13
90
#52931: The in operator produces True exactly when the first string appears in the second string. This is case sensitive: >>> 'a' in 'abc' True >>...more...
B8.0
15-Sep-13
90

#52469: In the second code example on the page:

>>> 'a' in 'abc'
True
>>> 'A' in 'abc'
True

The correct code should be:
>>> 'A' in 'abc'
False

B8.0
26-Aug-13
91
#77006: Throughout the text, chemical compounds that include oxygen (H2O, H2SO4, CO2, etc) are written with a zero instead of a capital letter O. F...more...
P1.0
14-Jul-14
92
#52452: Last line of last example on page reads "print "You should be careful with that!"" which is not valid syntax. It should read: "print("You sho...more...
B8.0
25-Aug-13
94

#53084: In the docstring "Return True iff x is positive," there's an extra "f"--Michael Fitzhugh

P1.0
29-Oct-13
96
#52556: I see that someone has already discussed this, but wouldn't it be better the replace the phrase "This code is the same as this:" with ...more...
B8.0
01-Sep-13
97

#52561: Isn't a colon missing in the first occurrence of "else" in the code at the bottom of the page?--James D Reid

B8.0
02-Sep-13
110
#52967: The whole of section 6.3 has an issue where the text refers to module temperature_program, which has 3 doctests, but the screenshots show the ...more...
P1.0
22-Sep-13
111
#52529: The second to last code snippet on the page reads: print("After import, __name__ is", __name__, \ "and echo.__name__ is", echo.__name__) ...more...
B8.0
31-Aug-13
111
#53229: Figure 5 shows the IDLE results of running baking.py, but the text discussing this on page 110 and the start of text on page 111 talks about t...more...
P1.0
29-Nov-13
121

#52545: "Here are two more examples, this time using the other two string methods
from the code on page 119."

Should be page 120.

B8.0
01-Sep-13
122
#52546: The code snippet at the top of the page: >>> help(math.sqrt) Help on built-in function sqrt in module math: should be prefixed by: >...more...
B8.0
01-Sep-13
125

#52552: The line:
these three functions to a string with leading and trailing whitespace:

"functions" should be replaced by "methods"

B8.0
01-Sep-13
126
#77005: This is not an error with the text, but an error with the exercise solutions at http: // pragprog (dot) com/wikis/wiki/PracProg2methods. So...more...
P1.0
14-Jul-14
140

#52974: First paragraph: all references to "celegans_phenotypes" should be "celegan_markers".

P1.0
23-Sep-13
146
#52581: In the box "Where did my list go?": "As we will discuss in Section 6.3, Testing Your Code Semiautomatically, on page 114" should be: ...more...
B8.0
05-Sep-13
171
#52983: Throughout the examples in this chapter newlines are removed using str.strip(). However in the Coursera course in the week 6 files exercise th...more...
P1.0
26-Sep-13
174
#53199: (in "The with Statement" section) A misleading oversimplification is given re. the purpose of the 'with' statement in Python: The book states...more...
P1.0
22-Nov-13
177
#52935: In the last paragraph before 10.1: "You’ll first learn how to open and read information from files. After that, you’ll learn about the diff...more...
B8.0
16-Sep-13
178

#52936: In the penultimate paragraph:

"calendar programs read and process ical files (),"

ical should be iCal and the "()"?

B8.0
16-Sep-13
180
#52937: First line of second paragraph: "The second statement, contents = example_file.read(), tells Python that you want" should read: "The ...more...
B8.0
16-Sep-13
180
#52938: First line of third paragraph reads: "The last statement, example_file.close(), releases all resources associated with" and should be: ...more...
B8.0
16-Sep-13
180
#52945: 2nd paragraph. The statements in the text a wrong. they are not the statements in the example. 2nd statement s/b contents = file.read() las...more...
P1.0
18-Sep-13
183

#52949: A call to function sum_number_pairs results in a TypeError. And before that module total needs to be imported.

P1.0
19-Sep-13
185

#52950: In the first paragraph, the line:

"programs using import tsdl, as shown in the next example. This allows us to"

should import time_series

P1.0
19-Sep-13
185

#52985: The type contract for function definition smallest_value is incorrect as it returns an int.

P1.0
26-Sep-13
186

#52984: In function definition smallest_value_skip there is no check for a '-' in the first data line after the header.

P1.0
26-Sep-13
186

#52986: The type contract for function definition smallest_value_skip is incorrect as it returns an int.

P1.0
26-Sep-13
187

#52942: Section 10.4: all references to "urllib.urlrequest" are incorrect. The correct module name is "urllib.request".

B8.0
17-Sep-13
189
#52951: Top of page: "We now face the same choice as with skip_header: we can put find_largest in a module (possibly tsdl)," The module name is "ti...more...
P1.0
19-Sep-13
190
#52952: First paragraph: "here is the same code without using tsdl.skip_header and find_largest as helper methods:" should be "time_series.skip_hea...more...
P1.0
19-Sep-13
193

#52953: In example at the top of the page, file "multimol.pdb" is not closed.

P1.0
19-Sep-13
196
#52987: Not so much an error as a redundant check in function definition read_molecule: if fields[0] == 'ATOM': is redundant as with the format ...more...
P1.0
26-Sep-13
213

#76373: "key/value pair listed is 'canada goose': 71" should be,
"key/value pair listed is 'canada goose': 183"--Azef Aziz

P1.0
05-Feb-14
219
#76531: It's most likely my error but when I run the first code under 11.3, "Storing Data Using Dictionaries", the bird_counts[] list never populates....more...
P1.0
12-Mar-14
220
#76399: This is not an error in the book, but for the explanation of exercise 5 on page 220 (Storing Data Using Other Collection Types). For the re...more...
P1.0
11-Feb-14
224
#53095: At the bottom of the page: def find_two_smallest(L): """ (list of float) -> tuple of (int, int) The type of the list in int not float...more...
P1.0
31-Oct-13
225

#53090: In "Find, Remove, Find" it is not the re-insertion that is the problem, but the removal, as min2 is obtained before the re-insertion.

P1.0
30-Oct-13
230
#53096: Last example on page: # Examine each value in the list in order for i in range(2, len(values)): should be: # Examine each value in the l...more...
P1.0
31-Oct-13
233
#76346: sea_level_press = [] sea_level_press_file = open('darwin.slp', 'r') for line in sea_level_press_file: sea_level_press.appen...more...
P1.0
28-Jan-14
233

#53097: In function definition:
def time_find_two_smallest(find_func, lst): the return statement has a period at the end of the statement.

P1.0
31-Oct-13
233

#53098: In the example on the page the file is opened for reading but never closed.

P1.0
31-Oct-13
239
#53145: Bottom of page: list[0:i] doesn't contain value, and 0 <= i <= len(lst) should be: list[0:i] doesn't contain value, and 0 <= i < len(...more...
P1.0
13-Nov-13
241
#53230: In the explanation of the function linear_search(), it says, "At the end, we return... len(list) if value wasn't in list.", but actually -1 is...more...
P1.0
29-Nov-13
243

#53147: function definition "time_it" has the type contract:

(function, object, list) -> number

which should be:

(function, list, object) -> number

P1.0
13-Nov-13
246

#76390: " while if it is greater than j, we should move j down." should be (i think), "while if it is greater than v, we should move j down."--Asif Aziz

P1.0
08-Feb-14
246

#76392: 'because L[i] isn't included in the range; instead...' should be (i think), 'because L[m] isn't included in the range....'--Asif Aziz

P1.0
09-Feb-14
248
#76393: code related to binary search, if __name__ == '__main__': import doctest doctest.testmod() will not display output unless docke...more...
P1.0
09-Feb-14
257

#76975: Figure 13—First few steps in selection sort
=>
Figure 13—First few steps in insertion sort

P1.0
09-Jul-14
260

#53151: The doctest for function definition bin_sort is incorrect as the function returns a sorted copy of the list.

P1.0
14-Nov-13
287

#53250: The example method at the bottom of the page:

def __str__(self):
""" (Member) -> str

The type contract should be:

""" (Faculty) -> str

P1.0
30-Nov-13
287
#77023: Variable paul = Faculty('Paul', 'Ajax', 'pgries@cs.toronto.edu', '1234') contains only string 'Paul', not 'Paul Gries' as suggested by the pri...more...
P1.0
19-Jul-14
291
#53251: End of first paragraph reads: rewritten to return a Molecule object instead of a list of tuples: should be: rewritten to return a Mol...more...
P1.0
30-Nov-13
302
#53114: The test case pattern at the top of the page: been expected = «the value we expect will be returned» What is the "been" on the ...more...
P1.0
05-Nov-13
304
#53115: Last paragraph on page: Following those steps, we created a variable, nums The variable in the docstring is "L" not nums". This error oc...more...
P1.0
05-Nov-13
328
#53275: First sentence of "Changing Colors": Almost all foreground colors can be set using the bg and fg keyword arguments, respectively. Should...more...
P1.0
04-Dec-13
335
#53276: Last sentence before the code: accessed using self.state, and its controllers are the methods upClick and quitClick. the 2 method names...more...
P1.0
04-Dec-13
337
#53292: Question 5 states: In Section 3.4, Using Local Variables for Temporary Storage, on page 39, should be: In Section 3.3, Defining Our O...more...
P1.0
06-Dec-13
343
#53258: The first line on the page: The Python equivalent is a type we haven’t seen before called bytes... This is incorrect. We were introduced...more...
P1.0
01-Dec-13
350
#76440: for c in countries: cur.exec('INSERT INTO PopByCountry VALUES (?, ?, ?)', (c[0], c[1], c[2])) can be simply presented as, ...more...
P1.0
19-Feb-14
360
#53264: Nowhere in this chapter are there instructions to close the connection to the database when you're finished working with it: con.close() ...more...
P1.0
02-Dec-13
371 367
#76383: In the index for "backslash", only the meaning of backslash in Windows directory paths is listed (P.174). The use of backslash as line-contin...more...
P1.0
07-Feb-14