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

Print each item on the same line unless the item is a double pipe (||). In that case, instead of printing the item, prin

Can you tell me what I am doing wrong.

Thanks.

mapping.py
TILES = ('-', ' ', '-', ' ', '-', '||',
         '_', '|', '_', '|', '_', '|', '||',
         '&', ' ', '_', ' ', '||',
         ' ', ' ', ' ', '^', ' ', '||'
)
for items in TILES:
    x = ||
    if items = x:
         output = tile.format("\n")
            else:
                output = tile.format(items)
            print(output, end+items)

1 Answer

The values in TILES are strings. Each item is closed in ' '. If you want x to check for the double pipe then set x='||'

x = '||'

later you call format on tile but I don't see where tile is created, so this would throw an error

HINT: When using print() it will automatically start a new line, unless you give it an extra parameter called end. If you set end = "" there will be no line return.

some_list = ['P', 'y', 't', 'h', 'o', 'n']
# default printing includes line return
for item in some_list:
    print(item)
# use optional end parameter
for item in some_list:
    print(item, end="")
>>> some_list = ['P', 'y', 't', 'h', 'o', 'n']
>>> for item in some_list:
...     print(item)
...
P
y
t
h
o
n

>>> for item in some_list:
...     print(item, end="")
...
Python