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
Robert Smedley
4,460 PointsCreating a grid
def draw_map(player): print(" _"*5) tile = "|{}"
for cell in CELLS:
x, y = cell
if x < 4:
line_end = ""
if cell == player:
output = tile.format("X")
else:
output = tile.format("_")
else:
line_end = "\n"
if cell == player:
output = tile.format("X|")
else:
output = tile.format("_|")
print output, line_end
This code creates a grid except the columns are all lined up underneath each other. Any suggestion on how to align the columns correctly beside each other would be greatly appreciated. This is part of the Dungeon game in the python course.
1 Answer
Shreyas Papinwar
2,371 Pointsthere seems some problem with the grid try comparing with this-
def draw_map(player, monster, door):
print(" _"*5)
tile = "|{}"
for cell in CELLS:
x, y = cell
if x < 4:
line_end = ""
if cell == player:
output = tile.format("X")
elif cell == door:
output = tile.format("D")
else:
output = tile.format("_")
else:
line_end = "\n"
if cell == player:
output = tile.format("X|")
elif cell == door:
output = tile.format("D|")
else:
output = tile.format("_|")
print(output, end=line_end)