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

mourad marzouk
mourad marzouk
5,560 Points

My code seems right but it's breaking on one line in the output

I'm getting this as a result


||_||
& _
^

not sure whats is going on in the 2nd row anyone know?

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

for tile in TILES:
    if tile == '||':
        line_end='\n'
    else:
        line_end=''
        output = tile
    print(output, end=line_end)

1 Answer

mourad marzouk
mourad marzouk
5,560 Points

I figured it out. for tile in TILES: if tile == '||': line_end='\n' output='' else: line_end='' output = tile print(output, end=line_end)

because I wasn't putting an output in the if went through it twice.