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 trialAbdulkadir Kollere
1,723 PointsTiles not giving right output
This always bothers me! I get the correct output in workspaces but the challenge gives me the error "Didn't get the right output". Anyone for the rescue?
See the attached code.
TILES = ('-', ' ', '-', ' ', '-', '||',
'_', '|', '_', '|', '_', '|', '||',
'&', ' ', '_', ' ', '||',
' ', ' ', ' ', '^', ' ', '||'
)
for tile in TILES:
line_end = ""
if tile != "||":
print(tile, end = line_end)
else:
line_end = "\n"
print(tile, end = line_end)
2 Answers
Stuart Wright
41,120 PointsNote that the challenge states:
"Print each item on the same line unless the item is a double pipe (||). In that case, instead of printing the item, print a new line (\n)."
You are currently printing the item as well as the new line.
Chris Freeman
Treehouse Moderator 68,441 PointsYou are very close. If the tile is the double-pipe then do not print that tile. Instead print a regular EOL:
TILES = ('-', ' ', '-', ' ', '-', '||',
'_', '|', '_', '|', '_', '|', '||',
'&', ' ', '_', ' ', '||',
' ', ' ', ' ', '^', ' ', '||'
)
for tile in TILES:
line_end = ""
if tile != "||":
print(tile, end = line_end)
else:
#line_end = "\n"
print("")