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

Petko Draganov
PLUS
Petko Draganov
Courses Plus Student 2,005 Points

just didnt get the right results here....

i know, that, im close to true, but all try all variants and didnt passed. In console running perfect. :( ?

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


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

2 Answers

Erika Suzuki
Erika Suzuki
20,299 Points

Hi,

You're almost there. You are printing || on each loop too because you're printing it first and then checking for it.

Correct answer would be:

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

for i in TILES:
    if i == '||':
        print()
    else:
        print(i, end='')

Notice the end='', it is to prevent print() function from using the default line-break.