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 trialLukas Coffey
20,382 PointsHave tried multiple solutions, will not pass (Didn't get the right output)
I have tried multiple ways to solve this challenge and can not get it to work. I have looked and tried all the different ways I found on the community, and none of those will work either. I am getting the "Bummer! Didn't get the right output" error.
TILES = ('-', ' ', '-', ' ', '-', '||',
'_', '|', '_', '|', '_', '|', '||',
'&', ' ', '_', ' ', '||',
' ', ' ', ' ', '^', ' ', '||'
)
for tile in TILES:
if tile == "||":
line_end = "\n"
output = "\n"
print(output, end=line_end)
else:
line_end = ""
print(tile, end=line_end)
2 Answers
Mike Wagner
23,559 PointsThe issue here is that the print function in Python 3 automatically defaults to
print('', end="\n")
so when you are calling
print("\n", end="\n")
you are adding an extra line. Changing the function call to
print('', end="\n")
# or even simply
print()
will give you a pass on the challenge and achieve the expected result:
- - -
_|_|_|
& _
^
in your console
Lukas Coffey
20,382 PointsThanks guys, I'm not sure why but other people got it right with different code! That worked though!
Mike Wagner
23,559 PointsNo problem. The thing that's hard to remember, sometimes, is that there are usually many, many ways to do the same thing. You were right on track for one of those ways, it just took a little finessing to get it the rest of the way.
Mike Wagner
23,559 PointsMike Wagner
23,559 Pointsof course you wont need the
on your double pipe check either.