learn python the hard way exercise 26 trouble
I am doing exercise 26 in learn python the hard way and have been struggling on it. I have read it backwards and everything, but in line 77 I get :
sentence = "All god \t things come to those who weight."
^
SyntaxError: invalid syntax
I dont know why the arrow is a开发者_如何转开发t the e . I dont just want to know how to fix it but what the problem is.
You're probably missing a close bracket, brace, or parenthesis on the previous line of code.
Edit: From the code:
print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont
There is no close parenthesis at the end of the line.
This is almost always the problem if you have a SyntaxError
near the beginning of a line that looks right.
The original statement is
sentence = "All god\tthings come to those who weight."
Make sure you typed it properly.
It's also possible that the code before this line is messed up.
EDIT: I checked the source, and it is broken: http://learnpythonthehardway.org/exercise26.txt
print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont
The open parenthesis was not closed.
There are several mistakes in the exercise26.txt
One of them is line 74 has a parenthesis that isn't closed:
print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont
should be
print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont)
(and probably start_point as start_pont isn't defined).
Syntax errors are usually on the line or the line above.
精彩评论