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

Peter Deitz
Peter Deitz
6,797 Points

Mapping.py working in shell but not passing code challenge

The following code is working fine for me in Workspaces but isn't passing the code challenge. Not sure what I'm missing or if the code challenge verification is throwing an error. Of course, my assumption is that I'm doing something wrong. Thanks for your help.

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

for i, char in enumerate(TILES):
    if char == '||':
        print("\n")
    else:
        print(char, end="")

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

The print includes a built-in end-of-line character. Use print("") instead of print("\n")

Peter Deitz
Peter Deitz
6,797 Points

That worked. I thought I had tried removing the \n before posting my question. I guess I hadn't. Thanks.