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

Andrew Bickham
Andrew Bickham
1,461 Points

dbl pipe line

im having trouble skipping over the dbl pipe lines; I can get them to start a new line but as far as skipping past them I cant quite seem to figure it out

mapping.py
TILES = ('-', ' ', '-', ' ', '-', '||',
         '_', '|', '_', '|', '_', '|', '||',
         '&', ' ', '_', ' ', '||',
         ' ', ' ', ' ', '^', ' ', '||'
)


for t in TILES:
    if t == "||":
        print(t, end="\n")
    else:
        print(t, end="")

1 Answer

Josh Keenan
Josh Keenan
20,315 Points

I just had a go and made the same mistake you have, if it is a double pipe it wants you to JUST print a new line, not the double pipe and the newline:

TILES = ('-', ' ', '-', ' ', '-', '||',
         '_', '|', '_', '|', '_', '|', '||',
         '&', ' ', '_', ' ', '||',
         ' ', ' ', ' ', '^', ' ', '||'
)

for char in TILES:
    if char == "||":
        print("\n")
    else:
        print(char, end="")
Andrew Bickham
Andrew Bickham
1,461 Points

lol well that's refreshing, but could you possibly explain why this coding worked but not the first attempt. honestly I feel like there the same coding

also thank you for the help josh

Josh Keenan
Josh Keenan
20,315 Points

because it wants you to not print the actual character.

    if t == "||":
        print(t, end="\n")

The challenge says print a new line if it is a double pipe, not print the double pipe then the new line like you have.

    if t == "||":
        print("\n")

So this is what you should have had in there, the only mistake you made was misreading the question, which is something I think I do an awful lot myself.

Josh Keenan
Josh Keenan
20,315 Points

Happy to help! Good luck and happy coding