Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Leah Miller
Leah Miller
16,291 Points

draw_map test dd_game.py

https://w.trhou.se/nipsptxkda

I can not figure out why I am getting the following error when trying a docstring test for the draw_map() method.


File "/home/treehouse/workspace/dungeon/dd_game.py", line 95, in dd_game.draw_map
Failed example:
draw_map()
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/doctest.py", line 1330, in __run
compileflags, 1), test.globs)
File "<doctest dd_game.draw_map[1]>", line 1, in <module>
draw_map()
File "/home/treehouse/workspace/dungeon/dd_game.py", line 105, in draw_map
for index, cell in enumerate(cells):
-----> NameError: name 'cells' is not defined


1 items had failures:
1 of 2 in dd_game.draw_map
Test Failed 1 failures.


I know I can compete it by just entering the coordinates for the cells as a list by is there away to do it using the existing methods in the app?

1 Answer

Josh Keenan
Josh Keenan
20,315 Points

Where are you getting cells from, on this line, 105:

    for index, cell in enumerate(cells):

You haven't defined cells within this function so you can't enumerate over something that has yet to come into existence. Define cells within the function, or as a global, or pass it in as a parameter. Hope this helps.