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!

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

What is making the third vertical wall in the dungeon?

I'm not stuck on the assignment (Building the Game: Part 2, where we complete the Dungeon game), just really puzzled.

I get that we've made the left and center row tiles equal to:

|_ or |X, depending on whether there's nothing or the player in that cell.

And I get that we've made the far-right wall with the else part of that statement into:

_| or X|, depending on whether there's nothing or the player in that cell.

But what in the world is making the third of the fourth walls in each row of this ASCII map? By my logic, it should look like this as only some boxes have a left wall and the far-right column does not have a left wall:


| _ | _ _| | _ | _ _| | _ | _ _|

Can someone help me wrap my head around this? I'm sure it's something really obvious and I'm not entirely sure why this even bothers me so much.

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

The tile is always |{}. For left or center, if the player is there, we use .format() to put in an X. If they're not, we put in _. For the rightmost column, if the player is there, we put in X|. If they're not, _|. So the right ends up being either |X| or |_|. That's what draws the right column's left wall.

Totally makes sense now, Kenneth. I guess I was getting delusional doing some of these at the end of a long day. Thanks!