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
17,364 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
17,364 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
17,364 Points

Happy to help! Good luck and happy coding