Invalid syntax from learn python the hard way text book


strong text

ex41. from learn python the hard way text book....dont know why i am getting syntax error in line which says error in line 45..."for sentence in snippet, phrase"..this is exactly what he wrote in his book,but can't figure why mine is wrong when i run the code...any help will be appreciated.

in ex43 of same book, it says my error is "current_scene is not defined".. and I have just written exactly what he wrote in the book....I will appreciate help for this question as well...thanks

Replace this line with your code.


Maybe what you run isn't an exact copy, you make it sound like you typed it in by hand. If you determined that your code is the same by eyeballing it, then that's your mistake. Make exact copies or make exact comparisons.


I was actually eyeballing them.....copy and paste made it work, thank you. I didn't want to do that before cos I thought it wasn't allowed. but If I tried to run a similar game of my own, will I not have a similar problem?


(1) This question is not really related to Codecademy.

(2) If you are looking for specific help with your code, it would be helpful to paste it, so we can see all of it and help you in determining what's wrong.

(3) From the sound of 2nd error message it seems that you did not define current_scene thing.

(4) Try thinking about what he writes in the book instead of writing exactly the same things. It sure can be helpful.


Yes, you're going to make mistakes when you write things. You get around it by fixing them. Syntax for instance is fairly trivial, particularly in python - so you'd just compare what you were doing with a reference (documentation/stack overflow being the main sources much of the time)
If instead you need an exact copy, then as said, make an exact one, or compare later if it wasn't. All it takes to make an exact comparison is loop through both and compare character by character, a trivial task for a computer, something poorly performed by humans, so we should just stay away.


Ok Jonatan, appreciate your contribution....hopefully I can move on from
here now and try what you have said...tnx


thank you Karaeska.. I will endeavour to do that next time..


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.