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

Not sure what's wrong with my codes.

I was told that "Did not get the correct result!". Yet, while I tested in Workspace, the result looks fine.

TILES = ('-', ' ', '-', ' ', '-', '||',
         '_', '|', '_', '|', '_', '|', '||',
         '&', ' ', '_', ' ', '||',
         ' ', ' ', ' ', '^', ' ', '||'
for s in TILES:
    if s == "||":
        line_end = "\n"
        print(s, end = line_end)
        line_end = ""
        print(s, end= line_end)
Zach Anderson
Zach Anderson
3,691 Points

You code will run and print things out but the instructions say:

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're adding a newline at the double pipes || which is correct, but you're also printing them print(s, end = line_end)

If that helped mark this as an answer. If not just reply back and I can help you out!

Cheers, -Zach

2 Answers

Mike Brooks
Mike Brooks
3,389 Points

You are printing variable s when adding the new line. Instructions say to print "\n" INSTEAD OF "||" . You could try changing your first print statement to: print('', end = line_end). Notice double single quotes instead of s

Thank you both! I did not read the requirements carefully enough.