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 Python Collections (2016, retired 2019) Dungeon Game Cartographer

Shane Smith
Shane Smith
4,383 Points

Can't get this grid to draw properly

The grid is supposed to be drawn in a 5 x 5 arrangement, however mine is just a row of 25 boxes any ideas what im doing wrong?

1 Answer

I had the same issue. My problem was that I had a wrong if statement. (Note: I have a width of 5 instead of 4 in Kenneth's example)

I had:

if x < 6:
    line_end=""
    #blabla more here
else:
    line_end="\n"
    #blabla more here

But the coordinates are zero based. So x < 6 is always the case cause the highest it will ever go is 5. This means that the new line character is never added so everything turns into one solid line of tiles.

So if I change it to:

if x < 5:
    line_end=""
    #blabla more here
else:
    line_end="\n"
    #blabla more here

My row turns into a 5x5 grid.