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 Line endings

Lukas Coffey
Lukas Coffey
20,382 Points

Have 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.

mapping.py
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

The 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

of course you wont need the

line_end = "\n"
output = "\n"

on your double pipe check either.

Lukas Coffey
Lukas Coffey
20,382 Points

Thanks guys, I'm not sure why but other people got it right with different code! That worked though!

No 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.