When I copied the code from that tutorial, I got similar errors (but with different line numbers), that were due to missing parentheses. This line (~16 lines from the bottom),
When you get error messages that seem to make no sense, look at the line numbers in the original code, since the code excerpt quoted in the error message is often off by a few lines.