[Tutor] Attribution Error

Alan Thwaits basicbare at gmail.com
Fri Apr 17 09:25:54 EDT 2020


I can't resolve an attribution error message in the script for my first
text-based rooms-and-choices game. After reading everything I could find
about it online, I'm still banging my head in frustration.  Any help,
direction, or suggestions would be greatly appreciated.

The error message I get is this:

Traceback (most recent call last):
  File "C:\Users\Alan\Documents\Python\ex45.py", line 350, in <module>
    a_game.play()
  File "C:\Users\Alan\Documents\Python\ex45.py", line 59, in play
    next_scene_name = current_scene.enter()
AttributeError: 'NoneType' object has no attribute 'enter'

The code blocks referenced in the above are:

# make a map, then hand it to an Engine before calling play to make the
game work
a_map = Map('aware')
a_game = Engine(a_map)
a_game.play()
 <<line 350


# set the Engine class and define it.
class Engine(object):

    def __init__(self, scene_map):
        self.scene_map = scene_map

    def play(self):
        current_scene = self.scene_map.opening_scene()
        last_scene = self.scene_map.next_scene('finished')

        while current_scene != last_scene:
            next_scene_name = current_scene.enter()          << line 59
            current_scene = self.scene_map.next_scene(next_scene_name)

        # be sure to print out the last scene
        current_scene.enter()

Thanks!

Alan


More information about the Tutor mailing list