[Tutor] python game error
steve at pearwood.info
Sat Oct 13 06:37:43 EDT 2018
On Sat, Oct 13, 2018 at 11:25:20AM +0300, Mariam Haji wrote:
> Hi guys,
> I am still on the learn python the hard way.
> I built the below on python 2.7 and my OS is windows 7.
> I am getting this error:
> Traceback (most recent call last):
> File "ex43.py", line 205, in <module>
> File "ex43.py", line 21, in play
> next_scene_name = current_scene.enter()
> AttributeError: 'NoneType' object has no attribute 'enter'
The current_scene variable currently is set to None, instead of athe
value that you think it has.
Try inserting the line
print repr(current_scene), type(current_scene)
just before line 21. Then you need to work out why it is set to None,
instead of whatever you expect it to be.
By the way, you shouldn't expect us to hunt through dozens or hundreds
of lines of code trying to debug your program for you. We're volunteers,
not being paid to do this. You should give us a *minimum* (small!)
example of your program.
That might mean keeping two copies, one which has all the irrelevant
code removed. (Like the dozens of calls to print -- not one
single one of those lines of code could possibly have anything
to do with the bug in your program.)
Removing that irrelevant code, cutting it down to a minimum, may even
help you find the bug yourself! Please read this for more information:
Even though this is written for Java programmers, the principles also
apply to Python.
> Main code is as, an I have highlighted line 21 and 205 in green below.
Have you? That explains why the indentation is messed up for me, making
the code impossible to understand correctly. And the green doesn't show up
in my email program.
Code is PLAIN TEXT, with no formatting. When you add formatting, like
colours, bold or italics, fancy fonts, animmated paperclips, etc, your
email program will destroy the indentation and make it unusable.
More information about the Tutor